Skip to content

Commit 47d6d71

Browse files
cjacekSquallATF
authored andcommitted
[LLD][COFF] Mark personality functions as live in both symbol tables on ARM64X (llvm#129295)
1 parent aa9af5a commit 47d6d71

File tree

2 files changed

+56
-7
lines changed

2 files changed

+56
-7
lines changed

lld/COFF/Driver.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2770,14 +2770,16 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
27702770
// For now, just manually try to retain the known possible personality
27712771
// functions. This doesn't bring in more object files, but only marks
27722772
// functions that already have been included to be retained.
2773-
for (const char *n : {"__gxx_personality_v0", "__gcc_personality_v0",
2774-
"rust_eh_personality"}) {
2775-
Defined *d = dyn_cast_or_null<Defined>(ctx.symtab.findUnderscore(n));
2776-
if (d && !d->isGCRoot) {
2777-
d->isGCRoot = true;
2778-
config->gcroot.push_back(d);
2773+
ctx.forEachSymtab([&](SymbolTable &symtab) {
2774+
for (const char *n : {"__gxx_personality_v0", "__gcc_personality_v0",
2775+
"rust_eh_personality"}) {
2776+
Defined *d = dyn_cast_or_null<Defined>(symtab.findUnderscore(n));
2777+
if (d && !d->isGCRoot) {
2778+
d->isGCRoot = true;
2779+
config->gcroot.push_back(d);
2780+
}
27792781
}
2780-
}
2782+
});
27812783
}
27822784

27832785
markLive(ctx);

lld/test/COFF/gc-dwarf-eh-arm64x.s

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# REQUIRES: aarch64
2+
3+
# RUN: llvm-mc -triple=aarch64-windows-gnu %s -filetype=obj -o %t-arm64.obj
4+
# RUN: llvm-mc -triple=arm64ec-windows-gnu %s -filetype=obj -o %t-arm64ec.obj
5+
# RUN: lld-link -machine:arm64x -lldmingw -out:%t.exe -opt:ref -entry:main %t-arm64.obj %t-arm64ec.obj -verbose 2>&1 | FileCheck %s
6+
# CHECK: Discarded unused
7+
8+
# Check that __gxx_personality_v0 is not discarded and is present in the output.
9+
10+
# RUN: llvm-objdump -d %t.exe | FileCheck --check-prefix=DISASM %s
11+
# DISASM: 0000000140001000 <.text>:
12+
# DISASM-NEXT: 140001000: 52800000 mov w0, #0x0 // =0
13+
# DISASM-NEXT: 140001004: d65f03c0 ret
14+
# DISASM-NEXT: 140001008: 52800020 mov w0, #0x1 // =1
15+
# DISASM-NEXT: 14000100c: d65f03c0 ret
16+
# DISASM-NEXT: ...
17+
# DISASM-NEXT: 140002000: 52800000 mov w0, #0x0 // =0
18+
# DISASM-NEXT: 140002004: d65f03c0 ret
19+
# DISASM-NEXT: 140002008: 52800020 mov w0, #0x1 // =1
20+
# DISASM-NEXT: 14000200c: d65f03c0 ret
21+
22+
.def main; .scl 2; .type 32; .endef
23+
.section .text,"xr",one_only,main
24+
.globl main
25+
main:
26+
.cfi_startproc
27+
.cfi_personality 0, __gxx_personality_v0
28+
mov w0, #0
29+
ret
30+
.cfi_endproc
31+
32+
.def __gxx_personality_v0; .scl 2; .type 32; .endef
33+
.section .text,"xr",one_only,__gxx_personality_v0
34+
.globl __gxx_personality_v0
35+
__gxx_personality_v0:
36+
mov w0, #1
37+
ret
38+
39+
.def unused; .scl 2; .type 32; .endef
40+
.section .text,"xr",one_only,unused
41+
.globl unused
42+
unused:
43+
.cfi_startproc
44+
.cfi_personality 0, __gxx_personality_v0
45+
mov w0, #2
46+
ret
47+
.cfi_endproc

0 commit comments

Comments
 (0)