diff options
author | Renato Golin <renato.golin@linaro.org> | 2016-06-27 14:42:20 +0000 |
---|---|---|
committer | Renato Golin <renato.golin@linaro.org> | 2016-06-27 14:42:20 +0000 |
commit | ef3eb066a9b91c9b9bfac6834b3ace799c7e9ec8 (patch) | |
tree | 90d9412a4583b8e048ba5ae09d1c56ca3dca8883 /llvm/lib/MC/MCObjectFileInfo.cpp | |
parent | 1e058160dd4e2d4dc17b02b79e8e30daad581b78 (diff) | |
download | llvm-ef3eb066a9b91c9b9bfac6834b3ace799c7e9ec8.zip llvm-ef3eb066a9b91c9b9bfac6834b3ace799c7e9ec8.tar.gz llvm-ef3eb066a9b91c9b9bfac6834b3ace799c7e9ec8.tar.bz2 |
[ARM] Fix Thumb text sections' flags under COFF/Windows
The main issue here is that the "thumb" flag wasn't set for some of these
sections, making MSVC's link.exe fails to correctly relocate code
against the symbols inside these sections. link.exe could fail for
instance with the "fixup is not aligned for target 'XX'" error. If
linking doesn't fail, the relocation process goes wrong in the end and
invalid code is generated by the linker.
This patch adds Thumb/ARM information so that the right flags are set
on COFF/Windows.
Patch by Adrien Guinet.
llvm-svn: 273880
Diffstat (limited to 'llvm/lib/MC/MCObjectFileInfo.cpp')
-rw-r--r-- | llvm/lib/MC/MCObjectFileInfo.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp index 5bbc8d5..d05bcea 100644 --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -595,7 +595,10 @@ void MCObjectFileInfo::initCOFFMCObjectFileInfo(const Triple &T) { COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE, SectionKind::getData()); - bool IsWoA = T.getArch() == Triple::arm || T.getArch() == Triple::thumb; + // Set the `IMAGE_SCN_MEM_16BIT` flag when compiling for thumb mode. This is + // used to indicate to the linker that the text segment contains thumb instructions + // and to set the ISA selection bit for calls accordingly. + const bool IsThumb = T.getArch() == Triple::thumb; CommDirectiveSupportsAlignment = true; @@ -606,7 +609,7 @@ void MCObjectFileInfo::initCOFFMCObjectFileInfo(const Triple &T) { SectionKind::getBSS()); TextSection = Ctx->getCOFFSection( ".text", - (IsWoA ? COFF::IMAGE_SCN_MEM_16BIT : (COFF::SectionCharacteristics)0) | + (IsThumb ? COFF::IMAGE_SCN_MEM_16BIT : (COFF::SectionCharacteristics)0) | COFF::IMAGE_SCN_CNT_CODE | COFF::IMAGE_SCN_MEM_EXECUTE | COFF::IMAGE_SCN_MEM_READ, SectionKind::getText()); |