dvp-objdump disassembly

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
mharris
Posts: 155
Joined: Sun Jan 25, 2004 2:26 pm
Location: Annapolis, MD, USA

dvp-objdump disassembly

Post by mharris »

The version of dvp-objdump that I have (built w/ Oopo's toolchain.sh, on Linux) does not seem to be capable of disassembling VU code correctly. It looks like it's always doing MIPS disassembly, regardless of the -m dvp:vu or other settings. I found a hook in the
binutils-2.14/opcodes/mips-dis.c module that checks to see if ARCH_dvp is defined, but the makefile only defines that for binutils-2.14/opcodes/disassemble.c

Rather than mess around w/ the hideous automake-generated makefiles to pass this flag on to mips-dis.c, I patched opcodes/disassemble.c directly. As a result, the dvp-objdump version will allow disassembly of vu code and vif/gif/dma packets, but will no longer disasm mips code (we have ee-objdump and iop-objdump for this anyhow).

The patch is ridiculously short, and seems to work for me:

Code: Select all

--- orig.binutils-2.14/opcodes/disassemble.c    2005-01-10 15:55:12.000000000 -0500
+++ binutils-2.14/opcodes/disassemble.c 2005-01-10 15:42:30.000000000 -0500
@@ -237,10 +237,14 @@
 #endif
 #ifdef ARCH_mips
     case bfd_arch_mips:
+#ifdef ARCH_dvp
+      disassemble = print_insn_dvp;
+#else /* !ARCH_dvp */
       if (bfd_big_endian (abfd))
        disassemble = print_insn_big_mips;
       else
        disassemble = print_insn_little_mips;
+#endif /* ARCH_dvp */
       break;
 #endif
 #ifdef ARCH_mmix
Apply this patch after the other binutils patch.
mharris
Posts: 155
Joined: Sun Jan 25, 2004 2:26 pm
Location: Annapolis, MD, USA

Post by mharris »

Hmm, looks like my patch may have broken EE disassembly via ee-objdump. It seems that ARCH_dvp is defined for the EE binutils configuration, and so any attempt to use the disassembler in ee-objdump treats the object file as a DVP object (VU, etc.), and won't show the R5900 opcodes as expected.

In the generated file build-ee/opcodes/Makefile (using ps2toolchain/toochain.sh), there are several references to the dvp, which I don't think should be there. This particular Makefile (the one in the opcodes dir) is the only one where it's present. A grep for 'dvp' in this file reveals:

Code: Select all

opcodes/Makefile:BFD_MACHINES =  mips-dis.lo mips-opc.lo mips16-opc.lo dvp-dis.lo dvp-opc.lo
opcodes/Makefile:archdefs =  -DARCH_mips -DARCH_dvp
opcodes/Makefile:OFILES =  mips-dis.lo mips-opc.lo mips16-opc.lo dvp-dis.lo dvp-opc.lo
opcodes/Makefile:     $(LIBTOOL) --mode=compile $(COMPILE) -c  -DARCH_mips -DARCH_dvp $(srcdir)/disassemble.c
opcodes/Makefile&#58;     $&#40;LIBTOOL&#41; --mode=compile $&#40;COMPILE&#41; -c  -DARCH_mips -DARCH_dvp $<
I'll dig around some more and see if I can find out why this is happening.
mharris
Posts: 155
Joined: Sun Jan 25, 2004 2:26 pm
Location: Annapolis, MD, USA

Post by mharris »

I am thinking that the cause of the error is the following lines in bfd/config.bfd (in the binutils project):

Code: Select all

case "$&#123;targ&#125;" in 
  mips64*-scei*-elf*&#41; targ_archs="$&#123;targ_archs&#125; bfd_dvp_arch" ;; 
esac 
It looks like whenever building for the mips64r5900el-scei-elf target, we automatically get dvp added as an additional target. These lines have been in the binutils patch for as far back as I can tell, so maybe it's been there all along (and my earlier 'fix' to the disassembly code just exposed it).

For anyone with more history on the toolchain than I have: can you think of a reason why the DVP stuff would have been added to the EE toolchain? Were these combined at one point (i.e., there were no separate dvp-* tools)?

I'm too tired right now to do a full regression test (which I should have done when I suggested the earlier patch back in January), so it'll have to wait until tomorrow before I can say whether or not this is the problem.
pixel
Posts: 791
Joined: Fri Jan 30, 2004 11:43 pm

Post by pixel »

Ah, huh, yeah, of course: you can build vu0 code for EE, since one of its behavior is to act as the ee's cop2. So, you need to have some of the dvp instruction support for EE. I think.... Huh.... doesn't sound right to me. I'll look at it whenever I found some spare minutes to do so :P
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
mharris
Posts: 155
Joined: Sun Jan 25, 2004 2:26 pm
Location: Annapolis, MD, USA

Post by mharris »

pixel wrote:Ah, huh, yeah, of course: you can build vu0 code for EE, since one of its behavior is to act as the ee's cop2. So, you need to have some of the dvp instruction support for EE. I think.... Huh.... doesn't sound right to me. I'll look at it whenever I found some spare minutes to do so :P
Mumble. Oh yeah, the COP2 instructions... right. OK, that idea won't work, gotta think of something else, I guess.
mharris
Posts: 155
Joined: Sun Jan 25, 2004 2:26 pm
Location: Annapolis, MD, USA

Post by mharris »

OK, think I've got it fixed now. Two simple changes to disassemble.c

Like I said, I'm gonna do as full a regression test as I can to make sure nothing's broken before releasing -- this includes building EE C source with inline COP2 VU instructions, micro-mode VU asm, and (just to be safe) some IOP stuff. I'll verify by using the corresponding disassemblies via objdump -d.

(Really, the only component that should be affected is the disassembly, but having been burned once, I don't want to release another buggy patch. Our QA department must have been asleep at the switch ;-P )
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

I'm certainly not QA. I usually wait for all the reports of problems to clear up, then run the latest toolchain script. :)
MrHTFord
Posts: 35
Joined: Tue Feb 10, 2004 2:04 am
Location: England

Post by MrHTFord »

I'll do some QA if you post the patch.
mharris
Posts: 155
Joined: Sun Jan 25, 2004 2:26 pm
Location: Annapolis, MD, USA

Post by mharris »

OK, finally I've gotten all three objdumps (ee, iop, dvp) to do what they're supposed to do. Here's the patch to binutils-2.14.patch.

If someone wants to give me cvs commit rights, I can pop it in myself.

Code: Select all

diff -u ps2toolchain/binutils-2.14.patch ps2toolchain.mharris/binutils-2.14.patch
--- ps2toolchain/binutils-2.14.patch           Wed Jan 19 23&#58;59&#58;53 2005
+++ ps2toolchain.mharris/binutils-2.14.patch   Fri Mar 11 04&#58;35&#58;00 2005
@@ -7099,28 +7099,21 @@
 diff -uNr binutils-2.14/opcodes/disassemble.c ps2-binutils-2.14/opcodes/disassemble.c
 --- binutils-2.14/opcodes/disassemble.c        Tue Apr  1 17&#58;50&#58;30 2003
 +++ ps2-binutils-2.14/opcodes/disassemble.c    Thu Jan 20 00&#58;59&#58;49 2005
-@@ -75,6 +75,9 @@
- #define INCLUDE_SHMEDIA
+@@ -232,12 +232,16 @@
+       disassemble = print_insn_mcore;
+       break;
  #endif
- 
-+#if defined &#40;ARCH_dvp&#41; && ! defined &#40;ARCH_mips&#41;  
-+#define ARCH_mips  
-+#endif  
- 
- disassembler_ftype
- disassembler &#40;abfd&#41;
-@@ -234,10 +237,14 @@
- #endif
- #ifdef ARCH_mips
+-#ifdef ARCH_mips
++#if defined&#40;ARCH_mips&#41; || defined&#40;ARCH_dvp&#41;
      case bfd_arch_mips&#58;
-+#ifdef ARCH_dvp
-+      disassemble = print_insn_dvp;
-+#else /* !ARCH_dvp */
++#ifdef ARCH_mips
        if &#40;bfd_big_endian &#40;abfd&#41;&#41;
        disassemble = print_insn_big_mips;
        else
        disassemble = print_insn_little_mips;
-+#endif /* ARCH_dvp */
++#else
++      disassemble = print_insn_dvp;
++#endif
        break;
  #endif
  #ifdef ARCH_mmix
Beware: the tabs may have gotten munged up when I posted it here, so you may have to finagle with the two lines that have tabs in them (the lines with 'disassemble = print_insn_xxx_mips;'); they must begin with space, space, tab or patch may get confused.
pixel
Posts: 791
Joined: Fri Jan 30, 2004 11:43 pm

Post by pixel »

Done. Please check I didn't break your patch :)
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
cory1492
Posts: 216
Joined: Fri Dec 10, 2004 1:49 pm

Post by cory1492 »

Here is the result I get (twice) trying to reinstall the toolchain with the new patches using ooPo's script:

Code: Select all

/bin/sh ./libtool --mode=link gcc -W -Wall -Wstrict-prototypes -Wmissing-prototy
pes -g -O2  -o cxxfilt.exe  cxxfilt.o bucomm.o version.o filemode.o ../bfd/libbf
d.la ../libiberty/libiberty.a ./../intl/libintl.a
gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -g -O2 -o cxxfilt.exe cxxf
ilt.o bucomm.o version.o filemode.o  ../bfd/.libs/libbfd.a ../libiberty/libibert
y.a ./../intl/libintl.a
make&#91;3&#93;&#58; Leaving directory `/tmp/ps2dev/binutils-2.14/build-ee/binutils'
make&#91;2&#93;&#58; Leaving directory `/tmp/ps2dev/binutils-2.14/build-ee/binutils'
make&#91;1&#93;&#58; Leaving directory `/tmp/ps2dev/binutils-2.14/build-ee/binutils'
Configuring in gas
loading cache .././config.cache
checking for Cygwin environment... &#40;cached&#41; yes
checking for mingw32 environment... &#40;cached&#41; no
checking host system type... i686-pc-cygwin
checking target system type... mips64r5900el-scei-elf
checking build system type... i686-pc-cygwin
checking for gcc... &#40;cached&#41; gcc
checking whether the C compiler &#40;gcc -g -O2 &#41; works... yes
checking whether the C compiler &#40;gcc -g -O2 &#41; is a cross-compiler... no
checking whether we are using GNU C... &#40;cached&#41; yes
checking whether gcc accepts -g... &#40;cached&#41; yes
checking for POSIXized ISC... no
checking for a BSD compatible install... &#40;cached&#41; /usr/bin/install -c
checking whether build environment is sane... yes
checking whether make sets $&#123;MAKE&#125;... &#40;cached&#41; yes
checking for working aclocal... missing
checking for working autoconf... missing
checking for working automake... missing
checking for working autoheader... missing
checking for working makeinfo... found
checking for ld used by GCC... &#40;cached&#41; /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/..
/../../../i686-pc-cygwin/bin/ld.exe
checking if the linker &#40;/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../../i686-p
c-cygwin/bin/ld.exe&#41; is GNU ld... &#40;cached&#41; yes
checking for /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../../i686-pc-cygwin/bi
n/ld.exe option to reload object files... &#40;cached&#41; -r
checking for BSD-compatible nm... &#40;cached&#41; nm
checking whether ln -s works... &#40;cached&#41; yes
checking how to recognise dependant libraries... &#40;cached&#41; file_magic file format
 pei*-i386&#40;.*architecture&#58; i386&#41;?
checking for object suffix... &#40;cached&#41; o
checking for executable suffix... &#40;cached&#41; .exe
checking for ranlib... &#40;cached&#41; ranlib
checking for strip... &#40;cached&#41; strip
updating cache .././config.cache
loading cache .././config.cache within ltconfig
checking for objdir... .libs
checking for gcc option to produce PIC...  -DDLL_EXPORT -DPIC
checking if gcc PIC flag  -DDLL_EXPORT -DPIC works... &#40;cached&#41; yes
checking if gcc static flag -static works... &#40;cached&#41; yes
finding the maximum length of command line arguments... &#40;cached&#41; 12289
checking if gcc supports -c -o file.o... &#40;cached&#41; yes
checking if gcc supports -fno-rtti -fno-exceptions ... no
checking whether the linker &#40;/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../../i
686-pc-cygwin/bin/ld.exe&#41; supports shared libraries... yes
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking dynamic linker characteristics... Win32 ld.exe
checking command to parse nm output... ok
checking if libtool supports shared libraries... yes
checking if package supports dlls... no
checking whether to build shared libraries... no
checking whether to build static libraries... yes
eval&#58; Cannot fork&#58; Permission denied
eval&#58; Cannot fork&#58; Permission denied
eval&#58; Cannot fork&#58; Permission denied
eval&#58; Cannot fork&#58; Permission denied
eval&#58; Cannot fork&#58; Permission denied
creating libtool
../../gas/../ltconfig&#58; rm&#58; permission denied
../../gas/../ltconfig&#58; Cannot fork&#58; Permission denied
../../gas/../ltconfig&#58; Cannot fork&#58; Permission denied
../../gas/../ltconfig&#58; Cannot fork&#58; Permission denied
../../gas/../ltconfig&#58; sed&#58; permission denied
../../gas/../ltconfig&#58; Cannot fork&#58; Permission denied
../../gas/../ltconfig&#58; chmod&#58; permission denied
../../gas/../ltconfig&#58; cat&#58; permission denied
../../gas/../ltconfig&#58; Cannot fork&#58; Permission denied
configure&#58; error&#58; libtool configure failed
make&#58; *** &#91;configure-gas&#93; Error 1
ERROR BUILDING BINUTILS &#40;binutils-2.14 ee&#41;
broken?? or just me?
mharris
Posts: 155
Joined: Sun Jan 25, 2004 2:26 pm
Location: Annapolis, MD, USA

Post by mharris »

checking whether to build static libraries... yes
eval: Cannot fork: Permission denied
eval: Cannot fork: Permission denied
eval: Cannot fork: Permission denied
eval: Cannot fork: Permission denied
eval: Cannot fork: Permission denied
I think it's just you, mate... I can't figure out why a fork() syscall would return EPERM, it's not supposed to.

It looks like you're building under cygwin -- are there any oddball permissions on directories that got messed up? Of course, you're running under windows, reboot and try again ;-)
cory1492
Posts: 216
Joined: Fri Dec 10, 2004 1:49 pm

Post by cory1492 »

the second time was after a reboot. I am reinstalling cygwin ATM to be sure perms werent messed about...

edit: did the reinstall, same error as before, will muck about with this more tomorrow and see if it still builds using the "broken" patches...

here is all I could find on this:
http://lists.blitzed.org/pipermail/bopm ... 00648.html
Im thinking my local install of cygwin is corrupted or something similar...

one last edit:
ok, after mucking about for a long time on this, I reinstalled cygwin (makes it the 3rd time in the last 24hrs), downloaded ps2toolchain-20050307.tgz from ooPos site and that built fine from start to finish. With the newest stuff from CVS it gets to the end of the first ./configure and starts spouting off about forks and permissions (on a clean install). I will attempt to narrow the problem by comaring the older files from the tgz to what is there now, but I have no idea what Im looking for so that will likely be a waste on my part.

ah well, I was looking for an excuse to build the toolchain under Xebian on the xbox anyways
cory1492
Posts: 216
Joined: Fri Dec 10, 2004 1:49 pm

Post by cory1492 »

after much head scratching and looking around at whatchamacallits, I wound up doing the download, extract and patch from oopos script, then restarted the pc and ran the script modded so it no longer looked to extract or create any files, just diving right into the compiling and so far so good, no fork problems (not on xebian, on cygwin). my fingers are crossed, ee-objdump would be handy indeed.

spoke too soon, it forked up when it tried to configure sed in gas... guess Ill just have to be patient and wait for lukasz to update his build for cygwin.
cory1492
Posts: 216
Joined: Fri Dec 10, 2004 1:49 pm

Post by cory1492 »

Ok, just built a virtual vmware Gentoo machine for doing the compiling - it actually works much faster than cygwin and has all of linux going for it.

The entire toolchain built flawlessly in less than 1/2 the time it take to go on cygwin. shift-delete-cygwin. thats all I can say ;)
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

I don't think anyone ever uses cygwin because they choose to. :)
MrHTFord
Posts: 35
Joined: Tue Feb 10, 2004 2:04 am
Location: England

Post by MrHTFord »

You could also have used my mingw patchset available on oopo's site...

...if I'd mentioned it to anyone, that is.

MrHTFord.
Post Reply