-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tool to help process SYM files #5
Comments
That's great! While there's a plugin to work with the .MAP files, they unfortunately do not contain structs and certain data. It would've been really nice to have everything filled in a few months ago in IDA haha! A potential challenge I see is that DIABPSX.BIN was split into several files, so the .SYM file will have to be interpreted accordingly and likely split into a file for each binary. It would also be nice to find a way to use the .SYM files in an emulator as well, so we can debug real-time without the console! |
This is actually part of the SYM file format :) The SYM file specifies overlays that will appear at the end of the executable. In the case of Diablo, there are four BIN files loaded in a similar fashion to dynamically linked libraries, and unloaded when no longer needed in order to save memory. These files are FMV.BIN, FRONTEND.BIN, PREGAME.BIN and GAME.BIN. find . -type f -iname '*.bin' | xargs ls -l | sort | xin
-rw-r--r-- 1 u users 126064 Jun 11 17:38 ./lump/FMV.BIN
-rw-r--r-- 1 u users 143924 Jun 11 17:38 ./lump/FRONTEND.BIN
-rw-r--r-- 1 u users 171468 Jun 11 17:38 ./lump/PREGAME.BIN
-rw-r--r-- 1 u users 172584 Jun 11 17:38 ./lump/GAME.BIN Each overlay has an overlay ID and an associated length specified in the SYM file.
Overlay From this we can determine the associated file of each overlay ID.
In later parts of the SYM file, the set overlay symbol specifies the start of symbol definitions related to a specific overlay, using the symbol header value to specify the overlay ID.
Definitely! Which PS1 emulators have SYM file support? |
Unfortunately, none that I know of. Currently the only option is to use a real-debugging unit hooked up to a PC. There was talk from the author about adding SYM support in No$PSX, but I don't think it ever happened. No$PSX is still the best emulator out there, and the only one with decent debugger support. |
Ok, starting to reach something useful. Install sym_dumpgo get -u github.com/sanctuary/sym/cmd/sym_dump Dump type definitionssym_dump -types DIABPSX.SYM Dump type definitions, variable and function declarationssym_dump -c DIABPSX.SYM Contents of header files stored at https://github.com/sanctuary/psx One thing that is recovered which was not part of https://github.com/sanctuary/psx is block information. This may help us understand how many for loops etc were in the original source, also, the local variable are associated with the correct block. E.g. // address: 0x8015F504
int SyncPutItem__FiiiiUsiUciiiiiUl(int pnum, int x, int y, int idx, int icreateinfo, int iseed, int Id, int dur, int mdur, int ch, int mch, int ivalue, unsigned long ibuff) {
int ii;
int d;
int dy;
{
{
{
{
{
{
unsigned char done;
{
int l;
{
{
int j;
{
int yy;
{
int i;
{
int xx;
}
}
}
}
}
}
}
}
}
}
}
}
} There is further information not yet pretty printed (e.g. line numbers, file name, but that information is now part of the Go data structures, so easy enough to print). In the next few weeks I hope to be able to clean this up a bit and provide a Good night :) |
I had forgotten we put these online a few months back. The scripts located at https://github.com/sanctuary/psx/tree/master/plugins can be used to import the symbols into IDA when analyzing the PSX version of Diablo. Run the following Python scripts from IDA to import the function signatures. base_types.py
name_diabpsx.py Just uploaded the latest version of the SYM dump to https://github.com/sanctuary/psx where overlay symbols have been split into dedicated header files. |
And we are good to go! IDA Python scripts uploaded to https://github.com/sanctuary/psx/tree/master/ida These are generated by running To install Below are step by step instructions for loading DIABPSX.BIN into IDA and running the above scripts to import symbol information. Load Diablo binary and overlay in IDA
Run IDA Python scriptsThe scripts are named as follows, with overlay IDs as below.
Assuming Step by step instruction for running scripts.
|
Would have been great to have that 6 months ago! Too bad IDA doesn't have a decompiler for the PSX though, and even then it doesn't seem to plug in the |
Hehe, yeah. Sorry for being late ^^
Indeed. I've been playing a bit with writing tools for PSX decompilation. Don't think they'll reach anything close to IDA in the near future, but it's been a lot of fun to play with.
Just for reference, how to calculate addresses from ; How to calculate global variable addresses in MIPS
$gp = 0x8011A780
; Example from drlg_l1.cpp___L5firstRoom(void)
seg003:8013D9C4 sb $zero, 0x215A($gp)
address: 0x8011A780 + 0x215A = 0x8011C8DA
sbss:8011C8DA HR3: .space 1 ; PSX ref: 0x8011C8DA
sbss:8011C8DA ; PSX def: unsigned char HR3 |
For the PAL "easy as pie" release: |
Oh, and to extract
Install the The executable files Edit: the |
There are also some raw source code files hidden in the "Easy as Pie"
|
Just stumbling upon this thread, but I'm not expecting to get a response on this due to the thread age. Info on how to parse/analyze .SYM files with IDA seems to be really sparse and some of the info linked here could be potentially useful, but seems its all 404'd. Is there any tool(s) still available in the public domain for .SYMs and IDA? |
Hi @ambiennt, The github.com/sanctuary/sym repo has now been made public. The code is in the public domain. Cheers, |
The last few days I've been playing with the idea of processing SYM files to output scripts which will add all symbol information to IDA. These scripts may be either in IDC format (e.g. notes.idc) or Python format (e.g. make_diablo.py and set_funcs).
As a first step to do this, we need to be able to process SYM files to the same capabilities as
DUMPSYM.EXE
.For this purpose, the https://github.com/sanctuary/sym repo was create; and as of today it is capable of parsing
DIABPSX.SYM
from both the Japanese SLPS-01416 release (i.e. jap_05291998.out) and the 1997-12-12 Easy as Pie release (i.e. pal_12121997.out), to produce identical output as theDUMPSYM.EXE
tool of the Psy-Q SDK.This is the initial step, and based on this we now have data structures to further process the information and produce useful high-level information; e.g. scripts for importing this information into IDA. Or, outputting C header files; etc.
Just wanted to post about the process and start to get input on directions to take, or ideas on what to play with :)
cc: @7i @galaxyhaxz @seritools
The text was updated successfully, but these errors were encountered: