Complete delink workflow; separate from decomp

We can now create a fresh Ghidra project, import the JSRF executable
into it, import symbols into it, delink object files from it, and then
decompile with objdiff.  Just needs some documentation.
This commit is contained in:
KeybadeBlox 2025-12-16 22:30:49 -05:00
parent 87c56f01d6
commit 1a48d4323e
17 changed files with 1178 additions and 8 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
# Can't distribute objects pulled from the JSRF executable
*.obj *.obj

View file

@ -14,8 +14,8 @@
"source_path": "src/Jet2.cpp" "source_path": "src/Jet2.cpp"
}, },
"symbol_mappings": { "symbol_mappings": {
"FUN_00187710": "$L514", "_main_handler": "$L522",
"FUN_0018771b": "$L522" "_main_handler_unwind1": "$L514"
} }
} }
] ]

View file

@ -1,6 +1,6 @@
#!/bin/sh -eu #!/bin/sh -eu
# Script to produce delinked object files in target/ directory from objects.csv # Script to produce delinked object files in decompile/target/ directory from
# and a Ghidra project via boricj's delinker extension # objects.csv and a Ghidra project via boricj's delinker extension
main() { main() {
if [ $# -ne 3 ]; then usage; fi if [ $# -ne 3 ]; then usage; fi
@ -62,7 +62,7 @@ delink() {
-postScript DelinkProgram.java\ -postScript DelinkProgram.java\
/exporter 'COFF relocatable object'\ /exporter 'COFF relocatable object'\
$(printf "/include-range %s " $4)\ $(printf "/include-range %s " $4)\
/export "target/$5" /export "../decompile/target/$5"
} }

42
delink/make_symboltable.sh Executable file
View file

@ -0,0 +1,42 @@
#!/bin/sh -eu
# Script to convert Ghidra symbol table CSV export data to the format used by
# the Ghidra script ImportSymbolsScript.py
main() {
if [ $# -ne 1 ]; then usage; fi
printf 'Writing symbol table to symboltable.tsv...'
>symboltable.tsv # Create/truncate output file
while IFS=, read -r name location type; do # Iterate over rows
# Determine symbol type (skip if unrecognized, e.g. header row)
if [ "$type" == '"Function"' ]; then type_out=f
elif [ "$type" == '"Data Label"' ]; then type_out=l
else continue
fi
# Strip quotes from other columns
name_out=${name#'"'} ; name_out=${name_out%'"'}
location_out=${location#'"'}; location_out=${location_out%'"'}
# Output row
printf '%s\t%s\t%s\n' "$name_out" "$location_out" "$type_out"\
>> symboltable.tsv
done < $1
printf ' done.\n'
}
usage() {
printf '%s\n'\
'Usage: make_symboltable.sh CSVFILE'\
' CSVFILE is the path of a symbol table CSV from Ghidra'\
''\
'The CSV file should have columns Name, Location, and Type. The output file'\
'will be named "symboltable.tsv".' >&2
exit 2
}
main "$@"

1127
delink/symboltable.tsv Normal file

File diff suppressed because it is too large Load diff

View file

@ -2,6 +2,7 @@
This is just a public holding space for anything I put together as a part of This is just a public holding space for anything I put together as a part of
the JSRF decompilation effort. the JSRF decompilation effort.
## `delink/`
`objects.csv` is a table of suspected object file boundaries for delinking. `objects.csv` is a table of suspected object file boundaries for delinking.
The addresses given in each section are runtime memory addresses (as one would The addresses given in each section are runtime memory addresses (as one would
see in e.g. Ghidra). see in e.g. Ghidra).
@ -9,8 +10,7 @@ see in e.g. Ghidra).
`delink.sh` is a script that produces delinked object files in `target/` from a `delink.sh` is a script that produces delinked object files in `target/` from a
Ghidra project. Ghidra project.
## `decompile/`
The `src/` directory contains decompiled code and data. Each symbol is The `src/` directory contains decompiled code and data. Each symbol is
annotated with its corresponding memory address in the original binary, and annotated with its corresponding memory address in the original binary, and
functions are marked as perfectly or imperfectly matching. It's not functions are marked as perfectly or imperfectly matching.
necessarily intended to be compilable, but more scratch space for noting down
what I've worked out.