- 论坛徽章:
- 0
|
发信人: Wwashington (Jacky), 信区: NewSoftware
标 题: [推荐] 几个Solaris下用的HexEditor和汇编工具
发信站: 水木社区 (Tue May 30 14:43:23 2006), 站内
Docs Title: [推荐] 几个Solaris下用的HexEditor和汇编工具
Publish On: 2006/05/30
Written By: Wwashington AT newsmth.org
前言:想必大家对 Win32 下的 Hex Editor 如 UltraEdit, WinHex, Hiew 等工具都
很熟悉了吧,这里介绍的是几个 Unix 下的工具,Hex Editor 是 shed, heme, biew,
Assembler 常用的是 yasm 和 nasm,还有一个是 Unix Disassembler,叫做 Udis86。
gdb 和 objdump 只能看 ELF 格式的,biew 和 udcli 则可以反汇编硬盘引导区。
说明:这个文档是我自己下载和编译时做的笔记,方便将来使用。发出来分享吧,在
格式上就没那么讲究了,大家按顺序往下看,自然就明白了。编译平台是 Solaris 9
U8 x86,以及 Companion CD 9U7。其中一些 alias 是来自我前几天那篇文章的附件,
需要的朋友这里下载,http://bbs.chinaunix.net/viewthread.php?tid=759675
-----------------------------------------------------------------------------
http://www.tech-faq.com/hex-editor.shtml
What is a hex editor?
http://www.rocketaware.com/spec/infotool/binedit/
Binary Editors
http://www.cspltd.ndirect.co.uk/programing/editors.htm
PROGRAMERS EDITORS
http://www.linuxmine.com/410.html
sed中如何替换出新行来
-----------------------------------------------------------------------------
http://swforum.sun.com/jive/thread.jspa?threadID=86603
MySQL 3.23 Installalation fails on Solaris 8
http://www.dbforums.com/showthread.php?t=529866
smpeg-0.4.3 will not compile on Solaris 8 X86
Gary Gibbings writes: --->
Assembler:
"/var/tmp/ccHuhxs7.s", line 1 : Illegal mnemonic
"/var/tmp/ccHuhxs7.s", line 1 : Syntax error
"/var/tmp/ccHuhxs7.s", line 3 : Illegal mnemonic
"/var/tmp/ccHuhxs7.s", line 3 : Syntax error
*** Error code 1
Juergen Keil writes: --->
This looks like a problem with the usage of the Sun assembler
/usr/ccs/bin/as vs. the GNU assembler gas. the following hack
should work to force gcc to use the gnu assembler:
cd /usr/ccs/bin
ln -s /opt/sfw/bin/gas gas
mv as as.sun
ln -s gas as
(or: ln -s as.sun as)
By changing the symbolic link /usr/ccs/bin/as to either point to the
original "as.sun" (Sun's assembler) or "gas" (GNU as) you can select
which version of the assembler is used during a GCC compilation.
-----------------------------------------------------------------------------
http://www.enlight.ru/qview/main.htm
Release 2.69.03 and update 2.80.01 are now available (DOS version only)!
http://rhack.sourceforge.net/
Hack is an hex editor designed to run under Win32 operating systems
http://www.technologismiki.com/en/index-h.html
Hackman Disassembler 9.0 is an ultra fast multi processor disassembler
http://biew.sourceforge.net/en/biew.html
BIEW- is multiplatform portable viewer of binary files with built-in editor
http://ag.qnx.org.ru/biew/
Here are present Binary vIEW (by Nick Kurshev) ported on QNX4 and on QNX6.
http://sourceforge.net/projects/nasm/
http://www.tortall.net/projects/yasm/releases/
-----------------------------------------------------------------------------
http://mirrors.kernel.org/gnu/gengetopt/gengetopt-2.16.tar.gz
http://ovh.dl.sourceforge.net/sourceforge/shed/shed-1.12.tar.gz
http://ovh.dl.sourceforge.net/sourceforge/heme/heme-0.4.tar.gz
http://www.tortall.net/projects/yasm/releases/yasm-0.4.0.tar.gz
http://ovh.dl.sourceforge.net/so ... 6/udis86-1.0.tar.gz
http://ovh.dl.sourceforge.net/so ... asm-0.98.39.tar.bz2
http://ovh.dl.sourceforge.net/sourceforge/biew/biew562.tar.bz2
cd /home/postgres/PgSrc
gzip -dc gengetopt-2.16.tar.gz | tar -xvf -
gzip -dc shed-1.12.tar.gz | tar -xvf -
gzip -dc heme-0.4.tar.gz | tar -xvf -
gzip -dc yasm-0.4.0.tar.gz | tar -xvf -
gzip -dc udis86-1.0.tar.gz | tar -xvf -
bunzip2 -dc nasm-0.98.39.tar.bz2 | tar -xvf -
bunzip2 -dc biew562.tar.bz2 | tar -xvf -
-----------------------------------------------------------------------------
cd gengetopt-2.16
./configure --prefix=/opt/sfw
make
make install
cp -pf src/getopt*.o /opt/sfw/share/gengetopt
ln -s gnugetopt.h /opt/sfw/share/gengetopt/getopt.h
ll /opt/sfw/share/gengetopt
cd ..
-----------------------------------------------------------------------------
cd shed-1.12
cp -pf /opt/sfw/share/gengetopt/getopt*.o .
export C_INCLUDE_PATH="/opt/sfw/include:/opt/sfw/share/gengetopt"
./configure --prefix=/opt/sfw
cat Makefile | grep "shed_OBJECTS ="
mv Makefile Makefile.old
cat Makefile.old | sed s/"shed_OBJECTS ="/"shed_OBJECTS = getopt.o getopt1.o"/g > Makefile
cat Makefile | grep "shed_OBJECTS ="
make
make install
cd ..
-----------------------------------------------------------------------------
cd heme-0.4
export C_INCLUDE_PATH="/opt/sfw/include"
cat heme.c | grep "curses.h"
mv heme.c heme.c.old
cat heme.c.old | sed s/"curses.h"/"ncurses.h"/g > heme.c
cat heme.c | grep "curses.h"
cat Makefile | /usr/xpg4/bin/grep -e "LDFLAGS =" -e "PREFIX =" -e "CC =" -e "install"
mv Makefile Makefile.old
cat Makefile.old | sed s/"LDFLAGS = -lcurses"/"LDFLAGS = -lncurses"/g > Makefile.1
cat Makefile.1 | sed s/"PREFIX = \/usr\/local"/"PREFIX = \/opt\/sfw"/g > Makefile.2
cat Makefile.2 | sed s/"TARGET = heme"/"TARGET = heme]CC = gcc"/g| tr ']' '\n' > Makefile.3
cat Makefile.3 | sed s/"install -s"/"install"/g > Makefile.4
cat Makefile.4 | sed s/"install -m"/"ginstall -m"/g > Makefile
rm -f Makefile.1 Makefile.2 Makefile.3 Makefile.4
cat Makefile | /usr/xpg4/bin/grep -e "LDFLAGS =" -e "PREFIX =" -e "CC =" -e "install"
make
make install
cd ..
-----------------------------------------------------------------------------
First you must upgrade these 3 components, compile and install them.
Otherwise the compiler or installer will make some strange mistakes.
By the way, we choose the most stable version instead of latest one.
ftp://ftp.sunfreeware.com/pub/fr ... sol9-intel-local.gz
http://mirrors.kernel.org/gnu/automake/automake-1.9.6.tar.gz
http://mirrors.kernel.org/gnu/libtool/libtool-1.5.20.tar.gz
cd /home/postgres/PgPkg
gzip -d gettext-0.14.1-sol9-intel-local.gz
pkgadd -d gettext-0.14.1-sol9-intel-local
gzip -dc automake-1.9.6.tar.gz | tar -xvf -
gzip -dc libtool-1.5.20.tar.gz | tar -xvf -
cd automake-1.9.6
./configure
make
make install
cd ..
cd libtool-1.5.20
./configure
make
make install
cd ..
-----------------------------------------------------------------------------
cd /home/postgres/PgSrc
cd yasm-0.4.0
loc
hash -r
aclocal
autoconf
automake
export CPPFLAGS="-I/opt/sfw/include"
./configure --prefix=/opt/sfw
make
make install
yasm --version | grep yasm
cd ..
exit
bash
cd /home/postgres/PgSrc
cd udis86
export CPPFLAGS="-I/opt/sfw/include"
./configure --prefix=/opt/sfw
make
make install
udcli -h
cd ..
cd nasm-0.98.39
export CPPFLAGS="-I/opt/sfw/include"
./configure --prefix=/opt/sfw
make everything
make install_everything
nasm -v
cd ..
cds
cd ../Sun09/Old
udcli -16 PBoot
heme PBoot
shed PBoot
-----------------------------------------------------------------------------
echo "Prepare compiler environment to avoid Illegal mnemonic and Syntax error"
cd /usr/ccs/bin
ln -s /opt/sfw/bin/gas gas
[ -r as.sun ] || mv as as.sun
ln -s gas as
cd /usr/bin
ln -s /opt/sfw/bin/granlib granlib
ln -s granlib ranlib
cd /home/postgres/PgSrc
cd biew-562
mv makefile Makefile.old
cat Makefile.old | /usr/xpg4/bin/grep -e INCS -e LIBS
cat Makefile.old | sed s/"INCS ="/"INCS = -I\/opt\/sfw\/include"/g > Makefile.1
cat Makefile.1 | sed s/"LIBS ="/"LIBS = \/usr\/lib\/librt.so"/g > Makefile
rm -f Makefile.1
cat Makefile | /usr/xpg4/bin/grep -e INCS -e LIBS
cp ./biewlib/sysdep/generic/unix/vio.c vio.c.old
cat vio.c.old | grep curses.h
cat vio.c.old | sed s/"curses.h"/"ncurses.h"/g > vio.c.tmp
mv vio.c.tmp ./biewlib/sysdep/generic/unix/vio.c
cat ./biewlib/sysdep/generic/unix/vio.c | grep curses.h
make
cp -pf biew /opt/sfw/bin
mkdir -p /usr/local/share/biew/
cp -pf ./bin_rc/biew.hlp /usr/local/share/biew/
cp -pf ./bin_rc/skn/*.skn /usr/local/share/biew/
cp -pf ./bin_rc/syntax/*.stx /usr/local/share/biew/
ll /usr/local/share/biew/
biew -?
cd ..
[Notes] Error Messages if you don't modify Makefile and vio.c
Undefined first referenced
symbol in file
initscr32 ./biewlib/libbiew.a(vio.o)
nanosleep ./biewlib/libbiew.a(os_dep.o)
w32addch ./biewlib/libbiew.a(vio.o)
acs32map ./biewlib/libbiew.a(vio.o)
ld: fatal: Symbol referencing errors. No output written to biew
collect2: ld returned 1 exit status
make: *** [biew] Error 1
for i in /usr/include/*.h ; do echo $i; grep nanosleep $i; done
<-----
/usr/include/time.h
extern int nanosleep(const struct timespec *, struct timespec *);
----->
for i in /usr/lib/* ; do echo $i; grep nanosleep $i; done
<-----
/usr/lib/llib-lrt
int nanosleep(const struct timespec *, struct timespec *);
----->
for i in /usr/lib/*rt* ; do echo $i; done
-----------------------------------------------------------------------------
bash-2.05# which shed
/opt/sfw/bin/shed
bash-2.05# which heme
/opt/sfw/bin/heme
bash-2.05# shed /usr/platform/i86pc/lib/fs/ufs/pboot
bash-2.05# heme /usr/platform/i86pc/lib/fs/ufs/pboot
bash-2.05# gobjdump -D /usr/platform/i86pc/lib/fs/ufs/pboot
gobjdump: /usr/platform/i86pc/lib/fs/ufs/pboot: File format not recognized
bash-2.05# gobjdump -D /opt/sfw/bin/shed | less
-----------------------------------------------------------------------------
bash-2.05# gdb /opt/sfw/bin/shed
GNU gdb 5.3
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-pc-solaris2.9"...
(gdb) disas main
Dump of assembler code for function main:
0x8052b14 <main>: push %ebp
0x8052b15 <main+1>: mov %esp,%ebp
0x8052b17 <main+3>: push %edi
0x8052b18 <main+4>: push %esi
0x8052b19 <main+5>: sub $0x100,%esp
0x8052b1f <main+11>: and $0xfffffff0,%esp
0x8052b22 <main+14>: mov $0x0,%eax
0x8052b27 <main+19>: sub %eax,%esp
0x8052b29 <main+21>: lea 0xffffff98(%ebp),%edi
0x8052b2c <main+24>: mov $0x8054f50,%esi
0x8052b31 <main+29>: cld
---Type <return> to continue, or q <return> to quit---q
Quit
(gdb) quit
-----------------------------------------------------------------------------
It's not recommended to upgrade binutils, sometimes C lib is not compatible.
When a program really need gnu-ld, please set LD and NM, then run configure.
cd binutils-2.15
make
make install
cd ..
cd binutils-2.15
make uninstall
/* the uninstall target is not supported in this tree */
find . -name Makefile | xargs -i make -f {} uninstall
cd ..
/*******************************************
export LD=/opt/sfw/bin/gld
export NM=/opt/sfw/bin/gnm
export CPPFLAGS="-I/opt/sfw/include"
./configure --prefix=/opt/sfw --with-gnu-ld
*******************************************/
-----------------------------------------------------------------------------
[ 本帖最后由 wwashington 于 2006-6-8 13:45 编辑 ] |
|