ELF o/a to PSYQ obj/lib script

Discussion in 'Nintendo Game Development' started by babu, Oct 3, 2007.

  1. babu

    babu Mamihlapinatapai

    Joined:
    Apr 15, 2005
    Messages:
    2,945
    Likes Received:
    3
    !! WARNING !!

    This has been tested and works for me.. I can't guarantee it works for you. Use on own risk!

    !! END OF WARNING !!


    Finally got my N64 build environment up and running some day ago :)
    And noticed that my PSYQ libs wasn't up to date. So I wrote this crappy bash script to convert all ELF o/a files to PSYQ obj/lib and then I thought maybe someone else could use it too :shrug:

    save to ConvToPSYQ.sh:
    Code:
    #!/bin/sh
    # Converts o to obj and a to lib
    
    # Convert any archived o files.
    ConvArchive()
    {
    ls *.a|while read archiv; do
      # Create a working folder for current archive.
      dirnam=$archiv"_dir"
      mkdir $dirnam
    
      # Extract archive and delete.
      mv $archiv $dirnam"/"$archiv
      cd $dirnam
      ar x $archiv
      rm -f $archiv
    
      # Set new filename.
      archiv=${archiv%.a}.lib
    
      # Convert archived o files.
      ls *.o|while read fil; do
        elfconv $fil
        rm -f $fil
        fil=${fil%.o}.obj
        psylib2 -a $archiv $fil
        rm -f $fil
      done
    
      # Move to correct folder.
      mv $archiv ../$archiv
    
      # Proccess next archive.
      cd ..
      rm -f -r $dirnam
    done
    }
    
    # Convert any standalone o files.
    ls *.o|while read fil; do
      elfconv $fil
      rm $fil
    done
    
    # Convert archives.
    ConvArchive
    
    exit 0
    
    Usage (crapy guide):
    * You will need something like MinGW/MSYS or Cygwin to run.
    * You need the PSYQ toolchain (duh)
    * You need the search path to the psyq bin location in your PATH environment variable.

    1. Make a copy of your lib folder. !! Needed as this script WILL delete the o/a files after converting them. !!
    2. Put ConvToPSYQ.sh in this new folder.
    3. Open up MSYS and go to this folder.
    4. run the script.
    5. Wait...
    6. If you got anymore files to convert, like the .o files in the "PR" dir. Move ConvToPSYQ.sh there and repeat step 4-5 :)
    6. Done

    ex:
    # cd c:/ultra/newlib [ENTER]
    # ConvToPSYQ.sh [ENTER]
    ...
    # mv ConvToPSYQ.sh PR/ConvToPSYQ.sh
    # ConvToPSYQ.sh [ENTER]
    ...
     
    Last edited: Oct 3, 2007
  2. marshallh

    marshallh N64 Coder

    Joined:
    Mar 16, 2006
    Messages:
    661
    Likes Received:
    26
    Heh, reminds me I probably ought to convert that shiny new F3dEX2 ucode I have, it's reportedly a bit faster than the 97 version ;)
     
  3. babu

    babu Mamihlapinatapai

    Joined:
    Apr 15, 2005
    Messages:
    2,945
    Likes Received:
    3
    I basically did this b\c I had struggled for two days to get my code running, and then I accidentally noticed that I used old libs with newer headers making the linker whine >=/
    so I had to convert all o/a to obj/lib to use the header files.

    so what version is yours? I got something like Sept. 97 of the SN software and OS 2.0L is there anything more up to date out there?
     
  4. marshallh

    marshallh N64 Coder

    Joined:
    Mar 16, 2006
    Messages:
    661
    Likes Received:
    26
    Yea, I have the Sep97 bins as well (at least CCN64)

    I have only been able to get the 2.0K libs... I thought that was the last version?....
     
  5. babu

    babu Mamihlapinatapai

    Joined:
    Apr 15, 2005
    Messages:
    2,945
    Likes Received:
    3
    I don't know it says L on the installer :shrug:

    edit: but it feels more like a patch as it feels like lots of tools is missing (or maybe they come with the KMC disc?)
     
    Last edited: Oct 5, 2007
  6. kammedo

    kammedo and the lost N64 Hardware Docs

    Joined:
    Sep 24, 2004
    Messages:
    2,138
    Likes Received:
    12
    2.0L as far as i know should be the last one...it should have some references to the microcode used for RE2 too..

    EDIT : No, it doesnt. Jpeg microcode still was in beta when 2.0L was around.
     
    Last edited: Nov 17, 2007
  7. babu

    babu Mamihlapinatapai

    Joined:
    Apr 15, 2005
    Messages:
    2,945
    Likes Received:
    3
    yeah I saw that too. any idea on wether there was any more relases after it?

    btw. got me the kmc compiler. :)
    unfortantly it's pretty old (thought I don't know if any never version was relased) + I'm still missing some of those nice DD tools I read about in some manual >=/
     
    Last edited: Nov 18, 2007
  8. kammedo

    kammedo and the lost N64 Hardware Docs

    Joined:
    Sep 24, 2004
    Messages:
    2,138
    Likes Received:
    12
    Are available just up to version 5.1...in later versions they have been removed.
     
  9. babu

    babu Mamihlapinatapai

    Joined:
    Apr 15, 2005
    Messages:
    2,945
    Likes Received:
    3
    ah. crap. >=/
    looked pretty sweet
     
    Last edited: Nov 18, 2007
  10. marshallh

    marshallh N64 Coder

    Joined:
    Mar 16, 2006
    Messages:
    661
    Likes Received:
    26
    I'm trying to get a new libultra put together. The one I'm using is from 97, I have the later one though.

    The one I'm trying to convert to PsyQ is libgultra_rom.a from OS 2.0L. I used WinTar to extract it into a few hundred .o files.

    Elfconv *.o to get them into .obj files (psyq format)

    Finally psylib2 /a libgultra_rom.lib *.obj

    This works without a hitch (psylib crahses so I use psylib2)

    HOWEVER once I go to actually use it, psylink bitches about multiply defined symbols.
    C:/N64/LIB/EXPERIMENT/LIBGULTRA_ROM.LIB : Error : Symbol 'regdef.h' multiply defined
    C:/N64/LIB/EXPERIMENT/LIBGULTRA_ROM.LIB : Error : Symbol 'regdef.h' multiply defined
    C:/N64/LIB/EXPERIMENT/LIBGULTRA_ROM.LIB : Error : Symbol 'regdef.h' multiply defined
    C:/N64/LIB/EXPERIMENT/LIBGULTRA_ROM.LIB : Error : Symbol 'asm.h' multiply defined


    Then I dropped the .lib, and manually included each .obj individually. This told me which ones had the problem.

    C:/N64/LIB/EXPERIMENT/LIBGULTRA_ROM/MTXF2L.OBJ : Error : Symbol 'regdef.h' multiply defined
    C:/N64/LIB/EXPERIMENT/LIBGULTRA_ROM/MTXF2L.OBJ : Error : Symbol 'regdef.h' multiply defined
    C:/N64/LIB/EXPERIMENT/LIBGULTRA_ROM/MTXF2L.OBJ : Error : Symbol 'regdef.h' multiply defined
    C:/N64/LIB/EXPERIMENT/LIBGULTRA_ROM/MTXF2L.OBJ : Error : Symbol 'asm.h' multiply defined
    C:/N64/LIB/EXPERIMENT/LIBGULTRA_ROM/MTXIDENT.OBJ : Error : Symbol 'regdef.h' multiply defined
    C:/N64/LIB/EXPERIMENT/LIBGULTRA_ROM/MTXIDENT.OBJ : Error : Symbol 'regdef.h' multiply defined
    C:/N64/LIB/EXPERIMENT/LIBGULTRA_ROM/MTXIDENT.OBJ : Error : Symbol 'regdef.h' multiply defined
    C:/N64/LIB/EXPERIMENT/LIBGULTRA_ROM/MTXIDENT.OBJ : Error : Symbol 'asm.h' multiply defined
    C:/N64/LIB/EXPERIMENT/LIBGULTRA_ROM/MTXIDENTF.OBJ : Error : Symbol 'regdef.h' multiply defined
    C:/N64/LIB/EXPERIMENT/LIBGULTRA_ROM/MTXIDENTF.OBJ : Error : Symbol 'regdef.h' multiply defined
    C:/N64/LIB/EXPERIMENT/LIBGULTRA_ROM/MTXIDENTF.OBJ : Error : Symbol 'regdef.h' multiply defined
    C:/N64/LIB/EXPERIMENT/LIBGULTRA_ROM/MTXIDENTF.OBJ : Error : Symbol 'asm.h' multiply defined

    et cetera... I looked at the source of libultra, turns out these files came from .s files (r4300 assembly). only these files have problems.


    Any suggestions? (or babu can I borrow your lib file and see if it works? :))
     
  11. babu

    babu Mamihlapinatapai

    Joined:
    Apr 15, 2005
    Messages:
    2,945
    Likes Received:
    3
    Sorry for the delay, will check tonight if I still have the files.
     
sonicdude10
Draft saved Draft deleted
Insert every image as a...
  1.  0%

Share This Page