Skip to content

feat: implement stable gimphash calculation - #103

Open
Kudwa-Abhishek wants to merge 2 commits into
mandiant:masterfrom
Kudwa-Abhishek:fix/16-gimphash
Open

Kudwa-Abhishek wants to merge 2 commits into
mandiant:masterfrom
Kudwa-Abhishek:fix/16-gimphash

Conversation

@Kudwa-Abhishek

Copy link
Copy Markdown

Summary

Implements Gimphash calculation for Go binaries as requested in #16.

The implementation derives the hash from function names recovered from the binary's PCLN table and applies filtering and normalization intended to reduce noise from Go-generated and standard-library functions.

What changed

  • Added calculateGimphash() in gimphash.go.

  • Calculate Gimphash from the parsed PCLN function table.

  • Exclude compiler-generated symbols beginning with:

    • go.
    • go:
    • type.
    • type:
  • Normalize vendored function paths by removing the prefix through the last vendor/.

  • Exclude functions belonging to internal/ packages.

  • Exclude functions belonging to packages recognized by GoReSym's existing standard-library package list.

  • Sort the remaining function names before hashing so that function ordering does not affect the result.

  • Generate the final hash using SHA-256 over the concatenated normalized function names.

  • Add the calculated Gimphash to GoReSym's metadata and human-readable output.

  • Add unit tests covering:

    • user functions
    • internal package exclusion
    • unexported functions
    • unexported receivers
    • standard-library exclusion
    • compiler-generated symbol exclusion
    • vendor path normalization
    • order-independent hashing

Motivation

Gimphash is useful for identifying and comparing Go binaries based on their function composition.

The implementation builds on GoReSym's existing PCLN parsing and standard-library package identification rather than maintaining a separate hard-coded list of standard-library packages. Sorting the selected function names also avoids making the resulting hash dependent on their ordering in the PCLN table.

Testing

The focused Gimphash test passes:

go test -run TestCalculateGimphash

The project also builds successfully with:

go build

Related issue

Closes #16

image

@google-cla

google-cla Bot commented Oct 8, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@Kudwa-Abhishek

Copy link
Copy Markdown
Author

Hi maintainers, the Google CLA check has now passed. Thanks for your time! Whenever you get a chance, could you please review the PR? Happy to make any changes needed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: implement Gimphash calculation

1 participant