Skip to content

Commit 96d8502

Browse files
committed
[LLD][COFF] Add ARM64EC support to findLineTable.
1 parent 8f9903d commit 96d8502

File tree

2 files changed

+63
-10
lines changed

2 files changed

+63
-10
lines changed

lld/COFF/PDB.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,15 +1726,15 @@ void PDBLinker::commit(codeview::GUID *guid) {
17261726
}
17271727
}
17281728

1729-
static uint32_t getSecrelReloc(llvm::COFF::MachineTypes machine) {
1730-
switch (machine) {
1731-
case AMD64:
1729+
static uint32_t getSecrelReloc(Triple::ArchType arch) {
1730+
switch (arch) {
1731+
case Triple::x86_64:
17321732
return COFF::IMAGE_REL_AMD64_SECREL;
1733-
case I386:
1733+
case Triple::x86:
17341734
return COFF::IMAGE_REL_I386_SECREL;
1735-
case ARMNT:
1735+
case Triple::thumb:
17361736
return COFF::IMAGE_REL_ARM_SECREL;
1737-
case ARM64:
1737+
case Triple::aarch64:
17381738
return COFF::IMAGE_REL_ARM64_SECREL;
17391739
default:
17401740
llvm_unreachable("unknown machine type");
@@ -1752,7 +1752,7 @@ static bool findLineTable(const SectionChunk *c, uint32_t addr,
17521752
DebugLinesSubsectionRef &lines,
17531753
uint32_t &offsetInLinetable) {
17541754
ExitOnError exitOnErr;
1755-
const uint32_t secrelReloc = getSecrelReloc(c->file->ctx.config.machine);
1755+
const uint32_t secrelReloc = getSecrelReloc(c->getArch());
17561756

17571757
for (SectionChunk *dbgC : c->file->getDebugChunks()) {
17581758
if (dbgC->getSectionName() != ".debug$S")

lld/test/COFF/undefined-symbol-cv.s

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
# REQUIRES: x86
2-
# RUN: llvm-mc -triple=x86_64-windows-msvc -filetype=obj -o %t.obj %s
3-
# RUN: not lld-link /out:%t.exe %t.obj 2>&1 | FileCheck %s
1+
# REQUIRES: aarch64, x86
2+
# RUN: split-file %s %t.dir && cd %t.dir
3+
4+
# RUN: llvm-mc -triple=x86_64-windows-msvc -filetype=obj -o test-x86_64.obj test-x86_64.s
5+
# RUN: llvm-mc -triple=aarch64-windows-msvc -filetype=obj -o test-aarch64.obj test-aarch64.s
6+
# RUN: llvm-mc -triple=arm64ec-windows-msvc -filetype=obj -o test-arm64ec.obj test-aarch64.s
7+
8+
# RUN: not lld-link -out:test-x86_64.exe test-x86_64.obj 2>&1 | FileCheck %s
9+
# RUN: not lld-link -out:test-aarch64.exe test-aarch64.obj 2>&1 | FileCheck %s
10+
# RUN: not lld-link -out:test-arm64ec.exe -machine:arm64ec test-arm64ec.obj 2>&1 | FileCheck %s
11+
# RUN: not lld-link -out:test-arm64ec2.exe -machine:arm64ec test-x86_64.obj 2>&1 | FileCheck %s
412

513
# CHECK: error: undefined symbol: int __cdecl foo(void)
614
# CHECK-NEXT: >>> referenced by file1.cpp:1
@@ -18,6 +26,7 @@
1826
# CHECK-NEXT: >>> referenced by file1.cpp:5
1927
# CHECK-NEXT: >>> {{.*}}.obj:(f2)
2028

29+
#--- test-x86_64.s
2130
.cv_file 1 "file1.cpp" "EDA15C78BB573E49E685D8549286F33C" 1
2231
.cv_file 2 "file2.cpp" "EDA15C78BB573E49E685D8549286F33D" 1
2332

@@ -60,3 +69,47 @@ f2:
6069
.long 4
6170
.cv_filechecksums
6271
.cv_stringtable
72+
73+
#--- test-aarch64.s
74+
.cv_file 1 "file1.cpp" "EDA15C78BB573E49E685D8549286F33C" 1
75+
.cv_file 2 "file2.cpp" "EDA15C78BB573E49E685D8549286F33D" 1
76+
77+
.section .text,"xr",one_only,main
78+
.globl main
79+
main:
80+
.cv_func_id 0
81+
.cv_loc 0 1 1 0 is_stmt 0
82+
bl "?foo@@YAHXZ"
83+
.cv_loc 0 1 2 0
84+
bl "?foo@@YAHXZ"
85+
.cv_loc 0 2 3 0
86+
b "?bar@@YAHXZ"
87+
.Lfunc_end0:
88+
89+
f1:
90+
.cv_func_id 1
91+
.cv_loc 1 1 4 0 is_stmt 0
92+
bl "?bar@@YAHXZ"
93+
.Lfunc_end1:
94+
95+
.section .text,"xr",one_only,f2
96+
.globl f2
97+
f2:
98+
.cv_func_id 2
99+
.cv_loc 2 1 5 0 is_stmt 0
100+
bl "?baz@@YAHXZ"
101+
.Lfunc_end2:
102+
103+
.section .debug$S,"dr",associative,main
104+
.long 4
105+
.cv_linetable 0, main, .Lfunc_end0
106+
.cv_linetable 1, f1, .Lfunc_end1
107+
108+
.section .debug$S,"dr",associative,f2
109+
.long 4
110+
.cv_linetable 2, f2, .Lfunc_end2
111+
112+
.section .debug$S,"dr"
113+
.long 4
114+
.cv_filechecksums
115+
.cv_stringtable

0 commit comments

Comments
 (0)