Expand description
PSY-Q Library and Object File Parser
This crate provides parsing and manipulation capabilities for PSY-Q LIB and OBJ files, which were used by the official PlayStation 1 development toolchain and third-party toolchains for the Sega Saturn, Sega Genesis/MegaDrive/Sega CD/Mega CD, Super Nintendo, and others.
§Overview
PSY-Q was the official development kit for PlayStation 1 games. It produced two main types of binary files:
- LIB files: Archive files containing multiple object modules
- OBJ files: Individual object files with machine code and linking information
§Quick Start
Reading a library file:
use std::path::Path;
use psyk::io;
use anyhow::Result;
fn main() -> Result<()> {
let lib = io::read_lib(Path::new("LIBAPI.LIB"))?;
for module in lib.modules() {
println!("Module: {}", module.name());
println!("Created: {}", module.created());
println!("Exports: {:?}", module.exports());
}
Ok(())
}Reading either a LIB or OBJ file:
use std::path::Path;
use psyk::io;
use anyhow::Result;
fn main() -> Result<()> {
let lib_or_obj = io::read(Path::new("SOME.OBJ"))?;
println!("{}", lib_or_obj);
Ok(())
}Modules§
Structs§
- Code
- Machine code section.
- Def
- Variable or type definition debug information.
- Def2
- Extended variable or type definition with additional metadata.
- Export
- An exported symbol from a module.
- Filename
- A file name reference used in debug information.
- Function
Start - Function start debug information.
- Group
Symbol - A group symbol definition.
- LIB
- A LIB is an archive of several OBJ files. It consists of a magic number followed by one or more Modules.
- LNKHeader
- Section header information.
- Local
Symbol - A local symbol definition.
- Module
- A module entry in a LIB archive.
- Module
Metadata - Metadata for a module within a LIB archive.
- OBJ
- A PSY-Q object file (LNK format).
- Opaque
Module - An opaque module representation used during parsing.
- Patch
- A relocation patch to be applied by the linker.
- Procedure
Call - n.b.! this is completely untested and based on
assumptions from the output from
dumpobj. - Procedure
Definition - n.b.! this is completely untested and based on
assumptions from the output from
dumpobj. - Section
Offset Line - Section, Offset, and Line number information for source-line debugging.
- SetMX
Info - Set MX info directive.
- SetSLD
Line Num - Set source line debugger (SLD) line number.
- SetSLD
Line NumFile - Set source line debugger (SLD) line number with file reference.
- XBSS
- External BSS (uninitialized data) symbol.
- XDEF
- An external symbol definition (XDEF).
- XREF
- An external symbol reference (XREF).
Enums§
- Dim
- Dimension specification for arrays.
- Expression
- An expression used in relocations.
- Section
- A section within an OBJ file.
Traits§
- FromPSYQ
Timestamp - Trait for converting PSY-Q timestamps to standard Rust date/time types.