Sonic CD Gems Collection Linker Disassembly Dumps

Discussion in 'Engineering & Reverse Engineering' started by Ralakimus, Jun 12, 2022.

  1. Ralakimus

    Ralakimus

    Mommy says I'm just built different Tech Member
    627
    254
    63
    So, I've been digging at those ELF files for the Gems Collection version of Sonic CD. While objdump could be used to extract function and variable names, I noticed that it wasn't able to parse the .debug sections. The thing is that, there were definitely more symbols to extract, such as structure member names.

    Today, I did some more digging, and found this thread, which actually talked about my very issue, but for DDRMAX2. The very last post then took me to this post, which showed that someone successfully managed to extract data from the .debug section, and provided a batch script on how they did it.

    Gems Collection so happened to have been compiled and linked with the same tools as DDRMAX2, and I found an archive of those tools on archive.org, with cracks. So, I installed them and ran the Sonic CD ELF files from the PS2 version through the linker's disassembler, and...

    It worked.

    It's pure beauty. A much more complete dump of symbols with disassembled code from Sonic CD is now available.
     
    • Like Like x 4
    • Informative Informative x 3
    • List
  2. Alex Field

    Alex Field

    シュート! カオス・エメラルド・ザが消えようとしている! Member
    175
    108
    43
    Downunda, Mobius
    Sonic the Hedgehog 2+, Sonic the Hedgehog 3+
    HOLD ON A SECOND, there's a variable in this game known as "nTimerCunt"?!
    upload_2022-6-13_12-17-49.png
     
  3. Pobert-Eii

    Pobert-Eii

    Member
    67
    65
    18
    Where's the O? There was supposed to be a earth-shattering O!
     
  4. Brainulator

    Brainulator

    Regular garden-variety member Member
    The SMPS source code leak has this for the 68K version:
    Code (Text):
    1. rcunt        EQU    $01        ; delay count work
    2. cuntst        EQU    $02        ; delay store
    And this for the Z80 version:
    Code (Text):
    1. RCUNT        EQU    se_mode+1        ; For DLEAY COUNT NOTE LENGTH
    2. ;----------- 20 ----------------------
    3. CUNTST        EQU    RCUNT+1        ;
    Probably just a typo by people who are unaware of the English word. Kind of the inverse of how the Disney film The Emperor's New Groove had to have the main character's name, Kuzco, be renamed from Manco because of what that name means in Japan.
     
  5. Xiao Hayes

    Xiao Hayes

    Classic Eggman art Member
    I don't know in japanese, but, in spanish, you have to have lost your arm or at least your hand to be "manco". Not as unfortunate as the SCD one, though.
     
  6. biggestsonicfan

    biggestsonicfan

    Model2wannaB Tech Member
    1,435
    301
    63
    ALWAYS Sonic the Fighters
    Probably a dumb question, but would GHIDRA or IDA not do this automagically?
     
  7. Ralakimus

    Ralakimus

    Mommy says I'm just built different Tech Member
    627
    254
    63
    I'm not sure what's going on, but tools like IDA or objdump cannot parse the .debug section, hence why I even went through this process, even though apparently it is in a DWARF format. objdump was able to retrieve the filenames and line numbers from there, but for some reason couldn't recognize anything else. They're able to parse all the other symbols from other sections, though.
     
    Last edited: Jun 13, 2022
  8. biggestsonicfan

    biggestsonicfan

    Model2wannaB Tech Member
    1,435
    301
    63
    ALWAYS Sonic the Fighters
    Is there a .debug section for the other executables? Like Sonic the Fighters and Sonic R?
     
  9. Ralakimus

    Ralakimus

    Mommy says I'm just built different Tech Member
    627
    254
    63
    There's not much I can really do with those, as the only ELF files that I can really find don't really seem to be directly related to the games themselves, and even then, they appear to have their symbols stripped.
     
  10. biggestsonicfan

    biggestsonicfan

    Model2wannaB Tech Member
    1,435
    301
    63
    ALWAYS Sonic the Fighters
    I'd be interested to see if S0.DAT (Sonic the Fighters executable) produces anything useful if you wouldn't mind humoring me. If nothing directly related to the game is in there perhaps it could reveal something interesting about it's emulation.
     
  11. Ralakimus

    Ralakimus

    Mommy says I'm just built different Tech Member
    627
    254
    63
    Afraid that their debug symbols are also stripped out as well.
     
  12. biggestsonicfan

    biggestsonicfan

    Model2wannaB Tech Member
    1,435
    301
    63
    ALWAYS Sonic the Fighters
    Boooo.... but if you find some time, a confrimed executable with symbols exists in the PS2 Virtua Fighter 2 - Sega Ages 2500 does exist, and I do know that Sonic Gems shared the same emulation codebase. The StF executable and VF2 executables for PS2 both have the same strings "MW MIPS C Compiler (2.4.1.01).PlayStation2". I just feel any more information might be helpful in me trying to unravel aspects of that game.
     
  13. Ralakimus

    Ralakimus

    Mommy says I'm just built different Tech Member
    627
    254
    63
    I do link to the archive of the IDE and compiler/linker in the first post, so you may wanna check that out.
     
  14. biggestsonicfan

    biggestsonicfan

    Model2wannaB Tech Member
    1,435
    301
    63
    ALWAYS Sonic the Fighters
    I know I just wanted to be lazy and have it done by someone who's done it before already lol. Sigh, I don't use Windows so I will see what rabbit I can pull out of my hat for this.

    EDIT: Which of the installers should I be using?
     
    Last edited: Jun 14, 2022
  15. Ralakimus

    Ralakimus

    Mommy says I'm just built different Tech Member
    627
    254
    63
    The "mcwps2r3" one.
     
  16. biggestsonicfan

    biggestsonicfan

    Model2wannaB Tech Member
    1,435
    301
    63
    ALWAYS Sonic the Fighters
    Well I found the objdmp executable but how did you manage to spit out all the individual files like that?
     
    Last edited: Jun 15, 2022
  17. Ralakimus

    Ralakimus

    Mommy says I'm just built different Tech Member
    627
    254
    63
    You can run the linker separately. It's in the "PS2_Tools/Command_Line_Tools" folder in the installation path.
     
  18. biggestsonicfan

    biggestsonicfan

    Model2wannaB Tech Member
    1,435
    301
    63
    ALWAYS Sonic the Fighters
    My internet is crapping out on me and I didn't see this second post.

    Ah, so it seems .debug is stripped out of the executable and gives no new info. Boo!
     
  19. Ralakimus

    Ralakimus

    Mommy says I'm just built different Tech Member
    627
    254
    63
    The -S option produces an output file in mwldps2.