llvm.org GIT mirror llvm / ea3ab85
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 Saleem Abdulrasool 6 years ago
2 changed file(s) with 33 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
568568
569569
570570 void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) {
571 bool IsWoA = T.getArch() == Triple::arm || T.getArch() == Triple::thumb;
572
571573 // The object file format cannot represent common symbols with explicit
572574 // alignments.
573575 CommDirectiveSupportsAlignment = false;
581583 SectionKind::getBSS());
582584 TextSection =
583585 Ctx->getCOFFSection(".text",
586 (IsWoA ? COFF::IMAGE_SCN_MEM_16BIT : 0) |
584587 COFF::IMAGE_SCN_CNT_CODE |
585588 COFF::IMAGE_SCN_MEM_EXECUTE |
586589 COFF::IMAGE_SCN_MEM_READ,
0 @ RUN: llvm-mc -triple thumbv7-windows-itanium -filetype obj -o - %s \
1 @ RUN: | llvm-readobj -s - | FileCheck %s
2
3 .syntax unified
4 .thumb
5
6 .text
7
8 .def function
9 .type 32
10 .scl 2
11 .endef
12 .global function
13 .thumb_func
14 function:
15 bx lr
16
17 @ CHECK: Sections [
18 @ CHECK: Section {
19 @ CHECK: Name: .text
20 @ CHECK: Characteristics [
21 @ CHECK: IMAGE_SCN_ALIGN_4BYTES
22 @ CHECK: IMAGE_SCN_CNT_CODE
23 @ CHECK: IMAGE_SCN_MEM_16BIT
24 @ CHECK: IMAGE_SCN_MEM_EXECUTE
25 @ CHECK: IMAGE_SCN_MEM_PURGEABLE
26 @ CHECK: IMAGE_SCN_MEM_READ
27 @ CHECK: ]
28 @ CHECK: }
29 @ CHECK: ]