Include namespace in symbol table

This introduces its own issues, but without namespaces, symbol names end
up repeated and delinking fails.  The delinked symbols also end up
without namespaces, introducing yet more problems.  This is an
improvement for now, but we'll need proper namespace importing into
Ghidra at some point.
This commit is contained in:
KeybadeBlox 2026-02-01 21:11:26 -05:00
parent cef08bf624
commit 30f8a5879e
3 changed files with 817 additions and 791 deletions

View file

@ -9,19 +9,27 @@ main() {
>symboltable.tsv # Create/truncate output file
while IFS=, read -r name location type; do # Iterate over rows
while IFS=, read -r location namespace name type; do # Iterate 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
if [ "$type" = '"Function"' ]; then type_out=f
elif [ "$type" = '"Data Label"' ]; then type_out=l
else continue
fi
# Add namespace prefix if not in global namespace
if [ "$namespace" = '"Global"' ]; then namespace_out=
else
namespace_out=${namespace#'"'}
namespace_out=${namespace_out%'"'}::
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"\
printf '%s\t%s\t%s\n'\
"$namespace_out$name_out" "$location_out" "$type_out"\
>> symboltable.tsv
done < $1

File diff suppressed because it is too large Load diff

View file

@ -74,7 +74,9 @@ Double click it to open it in the CodeBrowser. The window that opens is where
you'll do all your in-situ analysis, should you choose to do so. You'll be
asked whether you want to run analyzers; say yes. Afterwards, simply clicking
"Analyze" in the analysis options window without changing anything is fine, and
the analysis will probably take a couple minutes.
the analysis will probably take a couple minutes. You can tell that the
analysis is still running if there's a progress bar in the bottom right saying
what it's currently analyzing.
There's a small oddity that needs fixing: certain parts of memory are marked as
executable where objdiff doesn't expect them to be, which will mess up our
@ -217,7 +219,10 @@ avoided by using namespaces if need be (i.e. `X::symbol` and `Y::symbol` may
coexist), but function overloading must be avoided (you may not have one
function with the signature `void X::f(int)` and another with the signature
`void X::f(float)`), else errors can arise when delinking, as the delinker
extension does not mangle symbol names.
extension does not mangle symbol names. Thunked functions can also cause
problems because Ghidra does not include them alongside other functions in the
symbol table, so convert them to regular functions (right click on the thunked
function in the symbol tree and unset it as a thunk in the `Function` submenu).
Once you're ready to export your symbols, open the symbol table
(`Window > Symbol Table`). Open the symbol filter window (cog button near the
@ -228,9 +233,10 @@ only export symbols that you've defined and that are useful for delinking.
Now we need to configure the columns that we want to export. Right-click on
one of the colum headers, click "Add/Remove Columns..." to open the "Select
Columns" window, and in it check only "Location," "Name," and "Type." Click
"OK" to close the window and ensure that the column order is "Name,"
"Location," "Type" (you can drag the column headers to reorder them if needed).
Columns" window, and in it check only "Location," "Name," "Namespace," and
"Type." Click "OK" to close the window and ensure that the column order is
"Location," "Namespace," "Name," "Type" (you can drag the column headers to
reorder them if needed).
Now, to actually export the table, right-click on one of the table cells, click
"Select All," and then right-click again on a cell to select "Export > Export