llvm.org GIT mirror llvm / 74a715d
[lli/COFF] Set the correct alignment for common symbols Otherwise we set it always to zero, which is not correct, and we assert inside alignTo (Assertion failed: Align != 0u && "Align can't be 0."). Differential Revision: https://reviews.llvm.org/D26173 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285841 91177308-0d34-0410-b5e6-96231b3b80d8 Davide Italiano 3 years ago
3 changed file(s) with 18 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
714714 void moveSymbolNext(DataRefImpl &Symb) const override;
715715 Expected getSymbolName(DataRefImpl Symb) const override;
716716 Expected getSymbolAddress(DataRefImpl Symb) const override;
717 uint32_t getSymbolAlignment(DataRefImpl Symb) const override;
717718 uint64_t getSymbolValueImpl(DataRefImpl Symb) const override;
718719 uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override;
719720 uint32_t getSymbolFlags(DataRefImpl Symb) const override;
154154
155155 uint64_t COFFObjectFile::getSymbolValueImpl(DataRefImpl Ref) const {
156156 return getCOFFSymbol(Ref).getValue();
157 }
158
159 uint32_t COFFObjectFile::getSymbolAlignment(DataRefImpl Ref) const {
160 // MSVC/link.exe seems to align symbols to the next-power-of-2
161 // up to 32 bytes.
162 COFFSymbolRef Symb = getCOFFSymbol(Ref);
163 uint32_t Value = Symb.getValue();
164 return std::min(uint64_t(32),
165 isPowerOf2_64(Value) ? Value : NextPowerOf2(Value));
157166 }
158167
159168 Expected COFFObjectFile::getSymbolAddress(DataRefImpl Ref) const {
0 ; RUN: opt -mtriple=x86_64-pc-win32-coff %s -o - | lli
1
2 @o = common global i32 0, align 4
3
4 define i32 @main() {
5 %patatino = load i32, i32* @o, align 4
6 ret i32 %patatino
7 }