Skip to content

fix(pe): skip indirect section names for PE images#532

Open
leno23 wants to merge 2 commits into
m4b:masterfrom
leno23:fix-pe-indirect-section-name-487
Open

fix(pe): skip indirect section names for PE images#532
leno23 wants to merge 2 commits into
m4b:masterfrom
leno23:fix-pe-indirect-section-name-487

Conversation

@leno23

@leno23 leno23 commented May 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add parse_indirect_section_names to ParseOptions (default: false for PE)
  • Only resolve /offset and //base64 COFF section name references when parsing COFF object files
  • Enable indirect section name parsing for Coff::parse via ParseOptions::coff()

Fixes #487

Test plan

  • cargo test --lib pe::section_table::tests
  • cargo test --lib string_table_excludes_length
  • New tests for PE literal /1234567 names and COFF indirect parsing

Indirect `/offset` section names are a COFF object-file feature. PE
images store UTF-8 names in the 8-byte section name field, so treat
leading slashes literally unless parsing a COFF object.

Fixes m4b#487

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

kkent030315 commented May 25, 2026

Copy link
Copy Markdown
Contributor

Thanks for the PR!

Relevant issue: #487

I think we need some discussion whether we really need this? I like this, but don't know if we should go this direction.

@leno23

leno23 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Resolved the merge conflict with upstream master in commit db586c8 and applied rustfmt to the PE COFF section parsing line.

During the merge, upstream added parse_imports while this branch added parse_indirect_section_names; both options are preserved. I also updated the PE indirect-section-name integration test to match the branch semantics: PE images keep /512 as the literal section name by default, while COFF-specific indirect parsing remains covered through ParseOptions::coff().

Local verification:

  • cargo fmt -- --check
  • cargo build
  • cargo test

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.

PE/COFF: Do not try to parse indirect section name in PE

2 participants