Skip to content

fix(pe): represent ordinal imports with name: None - #530

Closed
wyf027 wants to merge 2 commits into
m4b:masterfrom
wyf027:pe-import-name-option
Closed

fix(pe): represent ordinal imports with name: None#530
wyf027 wants to merge 2 commits into
m4b:masterfrom
wyf027:pe-import-name-option

Conversation

@wyf027

@wyf027 wyf027 commented May 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #38 by changing PE Import.name from Cow<str> to Option<Cow<str>>.

Ordinal-only imports no longer synthesize placeholder strings like "ORDINAL 51398". Instead, name is None and the ordinal field remains authoritative.

Breaking change

This is an API change for consumers that matched on the "ORDINAL {n}" string convention. They should now check name.is_none() and use ordinal.

Test plan

  • cargo test -p goblin --lib pe::import::tests

Use Option for PE Import names instead of synthesizing "ORDINAL N"
placeholders. Ordinal imports now expose None for name and keep the
ordinal field as the source of truth.

Fixes #38

Co-authored-by: Cursor <cursoragent@cursor.com>
@m4b

m4b commented May 25, 2026

Copy link
Copy Markdown
Owner

I guess this makes sense, I'd probably design it this way if I did it right now, but could you give some motivation for this PR? The ordinal is always "authoritative" afaik. Is there some usecase where you want to know if it truly didn't have an ordinal name (e.g., it was None)?

@kkent030315

Copy link
Copy Markdown
Contributor

@m4b this is BC right. so if we do this in future major bump, I believe we could do some major refactor for import table parser along with this?

@m4b

m4b commented May 25, 2026

Copy link
Copy Markdown
Owner

@kkent030315 yes, what other changes did you have in mind?

@wyf027

wyf027 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Resolved the rustfmt CI failure in commit bef45f7 by applying the formatter to src/pe/import.rs. Local verification: cargo fmt -- --check.

@wyf027 wyf027 closed this by deleting the head repository Jun 23, 2026
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.

EASY PE: should Import.name be option?

3 participants