MC: Support aligned COMMON symbols for COFF
authorDavid Majnemer <david.majnemer@gmail.com>
Sun, 21 Sep 2014 09:18:07 +0000 (09:18 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Sun, 21 Sep 2014 09:18:07 +0000 (09:18 +0000)
commit31b080d57faa4fb56aa8dbd3a054ab344e0f4c9e
tree14a2126ace921b1a44dbb50aec410101d32f4a84
parent1ca1e33c3aff32f14f54d3186ef840b94dfe3401
MC: Support aligned COMMON symbols for COFF

link.exe:
Fuzz testing has shown that COMMON symbols with size > 32 will always
have an alignment of at least 32 and all symbols with size < 32 will
have an alignment of at least the largest power of 2 less than the size
of the symbol.

binutils:
The BFD linker essentially work like the link.exe behavior but with
alignment 4 instead of 32.  The BFD linker also supports an extension to
COFF which adds an -aligncomm argument to the .drectve section which
permits specifying a precise alignment for a variable but MC currently
doesn't support editing .drectve in this way.

With all of this in mind, we decide to play a little trick: we can
ensure that the alignment will be respected by bumping the size of the
global to it's alignment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218201 91177308-0d34-0410-b5e6-96231b3b80d8
lib/MC/MCObjectFileInfo.cpp
lib/MC/WinCOFFStreamer.cpp
test/MC/COFF/comm.ll
test/MC/COFF/comm.s