Skip to content

Commit e896196

Browse files
authored
[LLD] [COFF] Fix deducing the machine type from LTO objects for ARM/Thumb (#71335)
In practice, all the Windows ARMNT IR objects show the architecture type Thumb, not ARM. Most other switch cases for architecture in lld/COFF check for and treat `arm` and `thumb` equally.
1 parent 05ed921 commit e896196

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lld/COFF/InputFiles.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,7 @@ MachineTypes BitcodeFile::getMachineType() {
10901090
case Triple::x86:
10911091
return I386;
10921092
case Triple::arm:
1093+
case Triple::thumb:
10931094
return ARMNT;
10941095
case Triple::aarch64:
10951096
return ARM64;

lld/test/COFF/lto-arm.ll

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; REQUIRES: arm
2+
3+
; RUN: llvm-as %s -o %t.obj
4+
5+
; RUN: lld-link /entry:entry %t.obj /out:%t.exe /subsystem:console 2>&1 | FileCheck %s --check-prefix=ERR --allow-empty
6+
; RUN: llvm-readobj %t.exe | FileCheck %s
7+
8+
; ERR-NOT: /machine is not specified
9+
10+
; CHECK: Format: COFF-ARM{{$}}
11+
; CHECK: Arch: thumb
12+
13+
target datalayout = "e-m:w-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
14+
target triple = "thumbv7-w64-windows-gnu"
15+
16+
define dso_local arm_aapcs_vfpcc void @entry() {
17+
entry:
18+
ret void
19+
}

0 commit comments

Comments
 (0)