Skip to content

Commit b1cc6f7

Browse files
authored
[LLD][COFF] Fix ARM64 EC chunks comparator. (#75495)
Spotted by Alexandre Ganea in #75407.
1 parent a171d24 commit b1cc6f7

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lld/COFF/Writer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,7 @@ void Writer::sortECChunks() {
14801480
llvm::stable_sort(sec->chunks, [=](const Chunk *a, const Chunk *b) {
14811481
std::optional<chpe_range_type> aType = a->getArm64ECRangeType(),
14821482
bType = b->getArm64ECRangeType();
1483-
return !aType || (bType && *aType < *bType);
1483+
return bType && (!aType || *aType < *bType);
14841484
});
14851485
}
14861486
}

lld/test/COFF/arm64ec-codemap.test

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ RUN: llvm-mc -filetype=obj -triple=arm64-windows arm64-func-sym.s -o arm64-func-
55
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows arm64ec-func-sym.s -o arm64ec-func-sym.obj
66
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows arm64ec-func-sym2.s -o arm64ec-func-sym2.obj
77
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows data-sec.s -o data-sec.obj
8+
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows data-sec2.s -o data-sec2.obj
89
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows empty-sec.s -o arm64ec-empty-sec.obj
910
RUN: llvm-mc -filetype=obj -triple=x86_64-windows x86_64-func-sym.s -o x86_64-func-sym.obj
1011
RUN: llvm-mc -filetype=obj -triple=x86_64-windows empty-sec.s -o x86_64-empty-sec.obj
@@ -119,8 +120,8 @@ DISASMM-NEXT: 18000200d: c3 retq
119120

120121
Merging data sections into code sections causes data to be separated from the code when sorting chunks.
121122

122-
RUN: lld-link -out:testdm.dll -machine:arm64ec arm64ec-func-sym.obj x86_64-func-sym.obj \
123-
RUN: data-sec.obj loadconfig-arm64ec.obj -dll -noentry -merge:.testdata=.text -merge:.rdata=test
123+
RUN: lld-link -out:testdm.dll -machine:arm64ec arm64ec-func-sym.obj x86_64-func-sym.obj data-sec.obj \
124+
RUN: data-sec2.obj loadconfig-arm64ec.obj -dll -noentry -merge:.testdata=.text -merge:.rdata=test
124125

125126
RUN: llvm-readobj --coff-load-config testdm.dll | FileCheck -check-prefix=CODEMAPDM %s
126127
CODEMAPDM: CodeMap [
@@ -135,6 +136,8 @@ DISASMDM: Disassembly of section .text:
135136
DISASMDM-EMPTY:
136137
DISASMDM-NEXT: 0000000180001000 <.text>:
137138
DISASMDM-NEXT: 180001000: 00000001 udf #0x1
139+
DISASMDM-NEXT: 180001004: 00000000 udf #0x0
140+
DISASMDM-NEXT: 180001008: 00000002 udf #0x2
138141
DISASMDM-NEXT: ...
139142
DISASMDM-NEXT: 180002000: 52800040 mov w0, #0x2
140143
DISASMDM-NEXT: 180002004: d65f03c0 ret
@@ -254,6 +257,10 @@ x86_64_func_sym2:
254257
.section .testdata, "rd"
255258
.xword 1
256259

260+
#--- data-sec2.s
261+
.section .testdata, "rd"
262+
.xword 2
263+
257264
#--- empty-sec.s
258265
.section .empty1, "xr"
259266
.section .empty2, "xr"

0 commit comments

Comments
 (0)