Skip to content

Commit 0fc791c

Browse files
authored
[BOLT] Fix comparison function for Linux ORC entries (#79921)
Fix ORC entry comparison function to cover a case with multiple terminator entries matching at the same IP.
1 parent a694104 commit 0fc791c

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

bolt/lib/Rewrite/LinuxKernelRewriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class LinuxKernelRewriter final : public MetadataRewriter {
9595
return 1;
9696
if (IP > Other.IP)
9797
return 0;
98-
return ORC == NullORC;
98+
return ORC == NullORC && Other.ORC != NullORC;
9999
}
100100
};
101101

bolt/test/X86/orc_unwind.s renamed to bolt/test/X86/linux-orc.s

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# REQUIRES: system-linux
22

3-
## Check that BOLT correctly reads ORC unwind information used by Linux Kernel.
3+
## Check that BOLT correctly reads ORC unwind information used by Linux kernel.
44

55
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
66
# RUN: %clang %cflags %t.o -o %t.exe
@@ -15,6 +15,7 @@
1515
# CHECK-NEXT: {sp: 16, bp: -16, info: 0x15}: foo
1616
# CHECK-NEXT: {sp: 16, bp: -16, info: 0x14}: foo
1717
# CHECK-NEXT: {sp: 8, bp: 0, info: 0x5}: foo
18+
# CHECK-NEXT: {sp: 0, bp: 0, info: 0x0}: bar
1819
# CHECK-NEXT: {sp: 0, bp: 0, info: 0x0}: bar
1920

2021
.text
@@ -50,7 +51,7 @@ foo:
5051
bar:
5152
.cfi_startproc
5253
ret
53-
# Same ORC info propagated from foo above.
54+
## Same ORC info propagated from foo above.
5455
# CHECK: retq # ORC: {sp: 8, bp: 0, info: 0x5}
5556
.L4:
5657
.cfi_endproc
@@ -61,7 +62,7 @@ bar:
6162
.section .orc_unwind_ip,"a",@progbits
6263
.align 4
6364

64-
# ORC for _start
65+
## ORC for _start.
6566
.section .orc_unwind
6667
.2byte 8
6768
.2byte 0
@@ -76,7 +77,7 @@ bar:
7677
.section .orc_unwind_ip
7778
.long foo - .
7879

79-
# ORC for foo
80+
## ORC for foo.
8081
.section .orc_unwind
8182
.2byte 8
8283
.2byte 0
@@ -112,7 +113,22 @@ bar:
112113
.section .orc_unwind_ip
113114
.long .L4 - .
114115

115-
# Fake Linux Kernel sections
116+
## Duplicate terminator entries to test ORC reader.
117+
.section .orc_unwind
118+
.2byte 0
119+
.2byte 0
120+
.2byte 0
121+
.section .orc_unwind_ip
122+
.long .L4 - .
123+
124+
.section .orc_unwind
125+
.2byte 0
126+
.2byte 0
127+
.2byte 0
128+
.section .orc_unwind_ip
129+
.long .L4 - .
130+
131+
## Fake Linux Kernel sections.
116132
.section __ksymtab,"a",@progbits
117133
.section __ksymtab_gpl,"a",@progbits
118134
.section .pci_fixup,"a",@progbits

0 commit comments

Comments
 (0)