summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MC/MCObjectFileInfo.cpp4
-rw-r--r--llvm/lib/MC/WinCOFFStreamer.cpp17
2 files changed, 16 insertions, 5 deletions
diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp
index da707d860a6..547630ea37d 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -595,9 +595,7 @@ void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) {
void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) {
bool IsWoA = T.getArch() == Triple::arm || T.getArch() == Triple::thumb;
- // The object file format cannot represent common symbols with explicit
- // alignments.
- CommDirectiveSupportsAlignment = false;
+ CommDirectiveSupportsAlignment = true;
// COFF
BSSSection =
diff --git a/llvm/lib/MC/WinCOFFStreamer.cpp b/llvm/lib/MC/WinCOFFStreamer.cpp
index 1d03e2d742f..2829a8ff0b5 100644
--- a/llvm/lib/MC/WinCOFFStreamer.cpp
+++ b/llvm/lib/MC/WinCOFFStreamer.cpp
@@ -183,8 +183,21 @@ void MCWinCOFFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
Symbol->getSection().getVariant() == MCSection::SV_COFF) &&
"Got non-COFF section in the COFF backend!");
- if (ByteAlignment > 32)
- report_fatal_error("alignment is limited to 32-bytes");
+ const Triple &T = getContext().getObjectFileInfo()->getTargetTriple();
+ if (T.isKnownWindowsMSVCEnvironment()) {
+ if (ByteAlignment > 32)
+ report_fatal_error("alignment is limited to 32-bytes");
+ } else {
+ // The bfd linker from binutils only supports alignments less than 4 bytes
+ // without inserting -aligncomm arguments into the .drectve section.
+ // TODO: Support inserting -aligncomm into the .drectve section.
+ if (ByteAlignment > 4)
+ report_fatal_error("alignment is limited to 4-bytes");
+ }
+ // Round size up to alignment so that we will honor the alignment request.
+ // TODO: We don't need to do this if we are targeting the bfd linker once we
+ // add support for adding -aligncomm into the .drectve section.
+ Size = std::max(Size, static_cast<uint64_t>(ByteAlignment));
AssignSection(Symbol, nullptr);
OpenPOWER on IntegriCloud