[NativeAOT] ObjWriter: Fix over-alignment of .eh_frame entries #96817
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ref: #95876 (comment)
Ref: https:/dotnet/llvm-project/blob/d8bacb4031b1d1e290ab2792e8378560419ee0de/llvm/lib/MC/MCDwarf.cpp#L1759-L1764
The DWARF specification requires the CIE/FDE entries in the
.eh_frame
sections to be aligned to pointer size. However, I incorrectly implemented it as the platform target pointer size, while it's supposed to be the DWARF pointer size specified in thepointer encoding
field. Since we use 4-byte relative pointers on all platforms this means the alignment is supposed to be on the 4-byte boundary, not on the 8-byte boundary.Tested on https:/aspnet/Benchmarks/tree/main/src/BenchmarksApps/BasicMinimalApi where we now produce the same size of
.eh_frame
section as the legacy ObjWriter. Prior to the fix the additional alignment contributed 53,736 bytes to the section size (out of roughly ~1MiB).