[PATCH] D34072: Fix alignment bug in COFF emission.
Zachary Turner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 12 13:19:46 PDT 2017
zturner added inline comments.
================
Comment at: llvm/lib/Object/WindowsResource.cpp:511
+
+ Current += SectionOnePadding;
}
----------------
ecbeckmann wrote:
> ruiu wrote:
> > Do you have to memorize how large was a padding? I mean you may be able to do this.
> >
> > Current = alignTo(Current, 8)
> Hmm doesn't that depend on the way the loader aligns cvtres in memory? For example, it could be possible for the system to align the FileOutputBuffer on 4 bytes instead of 8 bytes. So aligning to 8 bytes would actually be aligning to 4 bytes.
Not sure I follow your comment here. If the system aligns the `FileOutputBuffer` to 4 bytes (let's be explicit and say it puts it at address 4), and you call `Current = alignTo(Current, 8)` then after that call `Current` will be equal to 8, which is what you want, isn't it?
Seems to me like calling
```
X = OffsetToAlignment(Number, Align)
Number += X;
```
is mathematically equivalent to:
```
Number = alignTo(Number, Align);
```
https://reviews.llvm.org/D34072
More information about the llvm-commits
mailing list