Skip to content

feat(types): add Go baseline runtime types (string, slice, eface, iface, hmap) - #6831

Merged
wargio merged 8 commits into
rizinorg:devfrom
doomedraven:feature/golang-runtime-types
Oct 9, 2026
Merged

wargio merged 8 commits into
rizinorg:devfrom
doomedraven:feature/golang-runtime-types

Conversation

@doomedraven

@doomedraven doomedraven commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository.
  • I made sure to follow the project's coding style.
  • I've documented every RZ_API function and struct this PR changes.
  • I've added tests that prove my changes are effective (required for changes to RZ_API).
  • I've updated the Rizin book with the relevant information (if needed).
  • I've used AI tools to generate fully or partially these code changes and I'm sure the changes are not copyrighted by somebody else.

Detailed description
This PR introduces architecture-aware standard Go runtime data structures (stringStruct, string, slice, eface, iface, hmap) into Rizin's type subsystem and automatically loads them during Golang binary analysis.

Changes

  1. Type Definitions:
    • Added librz/arch/types/types-golang-32.sdb.txt and librz/arch/types/types-golang-64.sdb.txt.
    • Defined memory layouts and field offsets for canonical Go types:
      • struct stringStruct / typedef string
      • struct slice and struct runtime.slice
      • struct eface and struct runtime.eface
      • struct iface and struct runtime.iface
      • struct hmap and struct runtime.hmap
  2. Build System:
    • Registered types-golang-32 and types-golang-64 in sdb_types_files within librz/arch/types/meson.build.
  3. Core Analysis Integration:
    • Added rz_golang_load_types() in librz/core/golang.c.
    • Automatically loads the architecture-matched database upon discovering valid Go pclntab functions during rz_core_analysis_recover_golang_functions().
    • Lookup checks both system types_dir and user home_types_dir (~/.local/share/rizin/types).
    • Non-Golang binaries remain untouched to prevent type namespace pollution.

Relationship

Complements #6830 (Calling Conventions and ABI auto-assignment). Together, these provide the type foundation required by decompilers (rz-ghidra) and analysts to inspect Go parameters, return values, and memory buffers.

Test plan

  • Verified 138/138 unit tests pass (meson test -C build --suite unit).
  • Verified automatic loading on stripped Go ELF binary (ts / tc correctly emits struct definitions).
  • Verified non-Go binaries (/bin/ls) remain clean with zero type pollution.
  • Added test in test/db/analysis/golang to ensure Go runtime types (e.g. string) are loaded.

Closing issues

…ce, hmap)

- Add types-golang-32.sdb.txt and types-golang-64.sdb.txt defining canonical Go runtime structures (stringStruct, string, slice, eface, iface, hmap).
- Register types-golang-32 and types-golang-64 in sdb_types_files in librz/arch/types/meson.build.
- Load architecture-matched types-golang SDB during Go function recovery in rz_core_analysis_recover_golang_functions().
- Supports both system and user-home types search paths.
Comment thread librz/core/golang.c Outdated
Comment thread librz/core/golang.c Outdated
Comment thread test/db/analysis/golang Outdated
@doomedraven

Copy link
Copy Markdown
Contributor Author

thank you for review, addressed them all

@doomedraven doomedraven left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@doomedraven
doomedraven requested a review from wargio October 4, 2026 13:55

@wargio wargio left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@notxvilka have a look please because it seems wr are always applying the types here

notxvilka

This comment was marked as resolved.

@doomedraven
doomedraven force-pushed the feature/golang-runtime-types branch from 3854eae to 88410ae Compare October 8, 2026 05:29
@doomedraven
doomedraven requested a review from notxvilka October 8, 2026 05:56
@codecov

codecov Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.14286% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.37%. Comparing base (d1ee04a) to head (76fe48e).
⚠️ Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
librz/core/golang.c 57.14% 2 Missing and 4 partials ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
librz/core/golang.c 66.82% <57.14%> (-0.17%) ⬇️

... and 12 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d1ee04a...76fe48e. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@notxvilka notxvilka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. It made golang tests slightly slower though

@wargio
wargio merged commit 8c66632 into rizinorg:dev Oct 9, 2026
82 of 85 checks passed
@doomedraven
doomedraven deleted the feature/golang-runtime-types branch October 9, 2026 19:31
@doomedraven

Copy link
Copy Markdown
Contributor Author

yes sorry for that, i will see if i can make it better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants