[PATCH] D22776: [ARM] Set the thumb flag for all text segments on COFF (partial revert of recent commit)
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 27 05:15:29 PDT 2016
mstorsjo updated this revision to Diff 65711.
mstorsjo added a comment.
Updated the patch with changes requested before. Alternatively, https://reviews.llvm.org/D22855 can be used to fix the same issue in the clang driver instead.
https://reviews.llvm.org/D22776
Files:
lib/MC/MCObjectFileInfo.cpp
test/MC/ARM/Windows/thumb-attributes.s
Index: test/MC/ARM/Windows/thumb-attributes.s
===================================================================
--- /dev/null
+++ test/MC/ARM/Windows/thumb-attributes.s
@@ -0,0 +1,22 @@
+@ RUN: llvm-mc -triple armv7-windows-itanium -filetype obj -o - %s \
+@ RUN: | llvm-readobj -s - | FileCheck %s
+
+ .syntax unified
+ .thumb
+
+ .text
+
+ .global function
+ .thumb_func
+function:
+ bx lr
+
+@ CHECK: Sections [
+@ CHECK: Section {
+@ CHECK: Name: .text
+@ CHECK: Characteristics [
+@ CHECK-DAG: IMAGE_SCN_CNT_CODE
+@ CHECK-DAG: IMAGE_SCN_MEM_16BIT
+@ CHECK: ]
+@ CHECK: }
+@ CHECK: ]
Index: lib/MC/MCObjectFileInfo.cpp
===================================================================
--- lib/MC/MCObjectFileInfo.cpp
+++ lib/MC/MCObjectFileInfo.cpp
@@ -599,6 +599,13 @@
// 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;
+ // Windows on ARM is thumb only, and thus needs to set the IMAGE_SCN_MEM_16BIT
+ // flag. When the assembler is invoked via the clang driver, the triple is
+ // always set to arm-* (since the assembler always should start in ARM mode).
+ // Check for windows here, since we can't easily check the attributes of the
+ // contained individual functions here.
+ const bool IsWinARM = (T.isOSWindows() &&
+ (T.getArch() == Triple::arm || T.getArch() == Triple::thumb));
CommDirectiveSupportsAlignment = true;
@@ -609,7 +616,7 @@
SectionKind::getBSS());
TextSection = Ctx->getCOFFSection(
".text",
- (IsThumb ? COFF::IMAGE_SCN_MEM_16BIT : (COFF::SectionCharacteristics)0) |
+ ((IsThumb || IsWinARM) ? 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());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22776.65711.patch
Type: text/x-patch
Size: 1964 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160727/99a76aa9/attachment.bin>
More information about the llvm-commits
mailing list