Skip to content

Align final section to file alignment, not to virtual image size#124984

Merged
jkoritzinsky merged 1 commit intodotnet:mainfrom
jkoritzinsky:pe-file-size
Mar 11, 2026
Merged

Align final section to file alignment, not to virtual image size#124984
jkoritzinsky merged 1 commit intodotnet:mainfrom
jkoritzinsky:pe-file-size

Conversation

@jkoritzinsky
Copy link
Member

Fixes #124980

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts how PEObjectWriter determines the final on-disk size of emitted PE files so the file is padded only to file alignment, rather than being extended to the PE’s virtual image size (SizeOfImage), addressing reported self-contained app size regressions.

Changes:

  • Stop padding the output stream length to sizeOfImage.
  • Pad the final file length to _peFileAlignment instead.

Copy link
Member

@filipnavara filipnavara left a comment

Choose a reason for hiding this comment

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

Looks good to me in principle.

@agocke
Copy link
Member

agocke commented Mar 9, 2026

Let’s add a unit test somewhere

@agocke
Copy link
Member

agocke commented Mar 9, 2026

Native aot has a test that checks to see its size and then fails if it’s too big

@jkoritzinsky
Copy link
Member Author

Let’s add a unit test somewhere

I'll add some tests in a future PR for R2R size.

@jkoritzinsky jkoritzinsky merged commit c77d32c into dotnet:main Mar 11, 2026
108 of 111 checks passed
@jkoritzinsky jkoritzinsky deleted the pe-file-size branch March 11, 2026 20:43
@github-project-automation github-project-automation bot moved this to Done in AppModel Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Filesize regressions in self-contained apps in .NET 11

5 participants