Skip to content

Commit

Permalink
Merge pull request #265 from chaoticgd/dwarf_importer
Browse files Browse the repository at this point in the history
Add initial DWARF symbol importer
  • Loading branch information
chaoticgd authored Nov 28, 2024
2 parents 9af8baa + c21a127 commit 62c9964
Show file tree
Hide file tree
Showing 28 changed files with 2,684 additions and 624 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## v2.2

- **Added support for DWARF 1 symbol tables.**
- Improved support for bitfields.
- Improved support for 128-bit types.
- Added support for parsing .gnu.linkonce.* section names.
Expand Down
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,18 @@ add_library(ccc STATIC
src/ccc/data_refinement.h
src/ccc/dependency.cpp
src/ccc/dependency.h
src/ccc/dwarf_attributes.cpp
src/ccc/dwarf_attributes.h
src/ccc/dwarf_forge.cpp
src/ccc/dwarf_forge.h
src/ccc/dwarf_importer.cpp
src/ccc/dwarf_importer.h
src/ccc/dwarf_printer.cpp
src/ccc/dwarf_printer.h
src/ccc/dwarf_section.cpp
src/ccc/dwarf_section.h
src/ccc/dwarf_to_ast.cpp
src/ccc/dwarf_to_ast.h
src/ccc/elf.cpp
src/ccc/elf.h
src/ccc/elf_symtab.cpp
Expand Down Expand Up @@ -97,6 +107,7 @@ add_library(ccc_platform STATIC
set(TEST_SOURCES
test/demangler_tests.cpp
test/collision_tests.cpp
test/ccc/dwarf_importer_tests.cpp
test/ccc/elf_tests.cpp
test/ccc/int128_tests.cpp
test/ccc/mdebug_importer_tests.cpp
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Chaos Compiler Collection

A library and set of command line tools for parsing debugging symbols from PS2 games. The 1.x series of releases were focused on STABS symbols in .mdebug sections, while the 2.x series of releases can also parse standard ELF symbols and SNDLL linker symbols. DWARF support is planned.
A library and set of command line tools for parsing debugging symbols from PS2 games. The 1.x series of releases were focused on STABS symbols in .mdebug sections, while the 2.x series of releases can also parse standard ELF symbols and SNDLL linker symbols. DWARF support is in the works.

- [Releases](https://github.com/chaoticgd/ccc/releases)
- [Unstable Builds](https://github.com/chaoticgd/ccc/releases/tag/unstable)
Expand Down
2 changes: 1 addition & 1 deletion docs/JsonFormat.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and `ast_json.cpp` for the code that currently defines the format.

| Format Version | Release | Changes |
| - | - | - |
| 15 | v2.2 | The offset_bytes and bitfield_offset_bits properties of bitfield nodes now represent and are relative to the beginning of the storage unit respectively. |
| 15 | | The offset_bytes and bitfield_offset_bits properties of bitfield nodes now represent and are relative to the beginning of the storage unit respectively. |
| 14 | v2.1 | Added stack_frame_size property for function symbols. |
| 13 | v2.0 | Added size_bytes field to all nodes. Renamed data_type_handle property to just data_type (since it's not a handle). |
| 12 | | Added format and application properties to root object. Added hash property to function symbols. |
Expand Down
13 changes: 11 additions & 2 deletions docs/ProjectStructure.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
# Project Structure

- src/demangle.cpp: Main file for demangle.
- src/fuzztest.cpp: Fuzzing harness for libfuzzer.
- src/objdump.cpp: Main file for objdump.
- src/stdump.cpp: Main file for stdump.
- src/tests.cpp: Test runner.
- src/uncc.cpp: Main file for uncc.
- src/ccc/ast.cpp: Defines a C++ AST structure for types.
- src/ccc/ast_json.cpp: Reads/writes the AST structure as JSON.
- src/ccc/data_refinement.cpp: Converts global variable data into structured initializer lists and literals.
- src/ccc/dependency.cpp: Tries to infer information about which types belong to which files.
- src/ccc/dwarf_attributes.cpp: Parses DWARF 1 attributes.
- src/ccc/dwarf_forge.cpp: Generates DWARF 1 symbol tables for testing purposes.
- src/ccc/dwarf_importer.cpp: Imports DWARF 1 symbol tables into the symbol database.
- src/ccc/dwarf_printer.cpp: Prints out DWARF 1 symbol tables.
- src/ccc/dwarf_section.cpp: Parses the DWARF 1 binary format.
- src/ccc/dwarf_to_ast.cpp: Converts DWARF 1 types into a C++ AST.
- src/ccc/elf.cpp: Parses ELF files.
- src/ccc/elf_symtab.cpp: Parses the ELF symbol table.
- src/ccc/importer_flags.cpp: An enum and help information printing for importer configuration flags.
- src/ccc/int128.cpp: 128-bit integer types.
- src/ccc/mdebug_analysis.cpp: Accepts a stream of symbols and imports the data.
- src/ccc/mdebug_importer.cpp: Top-level file for parsing .mdebug symbol tables.
- src/ccc/mdebug_importer.cpp: Imports .mdebug (STABS) symbol tables into the symbol database.
- src/ccc/mdebug_section.cpp: Parses the .mdebug binary format.
- src/ccc/mdebug_symbols.cpp: Parses symbols from the .mdebug section.
- src/ccc/print_cpp.cpp: Prints out AST nodes as C++ code.
- src/ccc/registers.cpp: Enums for EE core MIPS registers.
- src/ccc/sndll.cpp: Parses SNDLL files and imports symbols.
- src/ccc/stabs.cpp: Parses STABS types.
- src/ccc/stabs_to_ast.cpp: Converts parsed STABS types into an AST.
- src/ccc/stabs_to_ast.cpp: Converts parsed STABS types into a C++ AST.
- src/ccc/symbol_database.cpp: Data structures for storing symbols in memory.
- src/ccc/symbol_file.cpp: Top-level file for parsing files containing symbol tables.
- src/ccc/symbol_json.cpp: Reads/writes the symbol database as JSON.
Expand All @@ -30,3 +38,4 @@
- src/mips/opcodes.h: Enums for different types of EE core MIPS opcodes.
- src/mips/tables.cpp: Table of EE core MIPS instructions.
- src/platform/file.cpp: Utility functions for reading files.
- tests/: Unit tests.
6 changes: 6 additions & 0 deletions src/ccc/ccc.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
#include "ast_json.h"
#include "data_refinement.h"
#include "dependency.h"
#include "dwarf_attributes.h"
#include "dwarf_forge.h"
#include "dwarf_importer.h"
#include "dwarf_printer.h"
#include "dwarf_section.h"
#include "dwarf_to_ast.h"
#include "elf.h"
#include "elf_symtab.h"
#include "importer_flags.h"
Expand Down
Loading

0 comments on commit 62c9964

Please sign in to comment.