diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-06-08 03:57:49 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-06-08 03:57:49 +0000 |
commit | ea3ab85c01df27a4dcd1a855b4cf5f3e2bdb2791 (patch) | |
tree | 706ef0a71983aef476f0acf68a69cb783719a71a /lib/MC | |
parent | 4a0c1d135eb8d3f1a3e71bb5aed02f59bc062125 (diff) | |
download | llvm-ea3ab85c01df27a4dcd1a855b4cf5f3e2bdb2791.tar.gz llvm-ea3ab85c01df27a4dcd1a855b4cf5f3e2bdb2791.tar.bz2 llvm-ea3ab85c01df27a4dcd1a855b4cf5f3e2bdb2791.tar.xz |
MC: fix text section characteristics for WoA
link.exe requires that the text section has the IMAGE_SCN_MEM_16BIT flag set.
Otherwise, it will treat the function as ARM. If this occurs, then jumps to the
function will fail, switching from thumb to ARM mode execution.
With this change, it is possible to link using the MSVC linker as well.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210415 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r-- | lib/MC/MCObjectFileInfo.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/MC/MCObjectFileInfo.cpp b/lib/MC/MCObjectFileInfo.cpp index d3d0832344..715dc844c7 100644 --- a/lib/MC/MCObjectFileInfo.cpp +++ b/lib/MC/MCObjectFileInfo.cpp @@ -569,6 +569,8 @@ 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; @@ -582,6 +584,7 @@ void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) { SectionKind::getBSS()); TextSection = Ctx->getCOFFSection(".text", + (IsWoA ? COFF::IMAGE_SCN_MEM_16BIT : 0) | COFF::IMAGE_SCN_CNT_CODE | COFF::IMAGE_SCN_MEM_EXECUTE | COFF::IMAGE_SCN_MEM_READ, |