-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[LLD][COFF] Mark personality functions as live in both symbol tables on ARM64X #129295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-lld-coff @llvm/pr-subscribers-lld Author: Jacek Caban (cjacek) ChangesFull diff: https://github.com/llvm/llvm-project/pull/129295.diff 2 Files Affected:
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 1589323073c09..b69ee2bf27742 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -2766,14 +2766,16 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
// For now, just manually try to retain the known possible personality
// functions. This doesn't bring in more object files, but only marks
// functions that already have been included to be retained.
- for (const char *n : {"__gxx_personality_v0", "__gcc_personality_v0",
- "rust_eh_personality"}) {
- Defined *d = dyn_cast_or_null<Defined>(ctx.symtab.findUnderscore(n));
- if (d && !d->isGCRoot) {
- d->isGCRoot = true;
- config->gcroot.push_back(d);
+ ctx.forEachSymtab([&](SymbolTable &symtab) {
+ for (const char *n : {"__gxx_personality_v0", "__gcc_personality_v0",
+ "rust_eh_personality"}) {
+ Defined *d = dyn_cast_or_null<Defined>(symtab.findUnderscore(n));
+ if (d && !d->isGCRoot) {
+ d->isGCRoot = true;
+ config->gcroot.push_back(d);
+ }
}
- }
+ });
}
markLive(ctx);
diff --git a/lld/test/COFF/gc-dwarf-eh-arm64x.s b/lld/test/COFF/gc-dwarf-eh-arm64x.s
new file mode 100644
index 0000000000000..d169256a3d985
--- /dev/null
+++ b/lld/test/COFF/gc-dwarf-eh-arm64x.s
@@ -0,0 +1,47 @@
+# REQUIRES: aarch64
+
+# RUN: llvm-mc -triple=aarch64-windows-gnu %s -filetype=obj -o %t-arm64.obj
+# RUN: llvm-mc -triple=arm64ec-windows-gnu %s -filetype=obj -o %t-arm64ec.obj
+# RUN: lld-link -machine:arm64x -lldmingw -out:%t.exe -opt:ref -entry:main %t-arm64.obj %t-arm64ec.obj -verbose 2>&1 | FileCheck %s
+# CHECK: Discarded unused
+
+# Check that __gxx_personality_v0 is not discarded and is present in the output.
+
+# RUN: llvm-objdump -d %t.exe | FileCheck --check-prefix=DISASM %s
+# DISASM: 0000000140001000 <.text>:
+# DISASM-NEXT: 140001000: 52800000 mov w0, #0x0 // =0
+# DISASM-NEXT: 140001004: d65f03c0 ret
+# DISASM-NEXT: 140001008: 52800020 mov w0, #0x1 // =1
+# DISASM-NEXT: 14000100c: d65f03c0 ret
+# DISASM-NEXT: ...
+# DISASM-NEXT: 140002000: 52800000 mov w0, #0x0 // =0
+# DISASM-NEXT: 140002004: d65f03c0 ret
+# DISASM-NEXT: 140002008: 52800020 mov w0, #0x1 // =1
+# DISASM-NEXT: 14000200c: d65f03c0 ret
+
+ .def main; .scl 2; .type 32; .endef
+ .section .text,"xr",one_only,main
+ .globl main
+main:
+ .cfi_startproc
+ .cfi_personality 0, __gxx_personality_v0
+ mov w0, #0
+ ret
+ .cfi_endproc
+
+ .def __gxx_personality_v0; .scl 2; .type 32; .endef
+ .section .text,"xr",one_only,__gxx_personality_v0
+ .globl __gxx_personality_v0
+__gxx_personality_v0:
+ mov w0, #1
+ ret
+
+ .def unused; .scl 2; .type 32; .endef
+ .section .text,"xr",one_only,unused
+ .globl unused
+unused:
+ .cfi_startproc
+ .cfi_personality 0, __gxx_personality_v0
+ mov w0, #2
+ ret
+ .cfi_endproc
|
mstorsjo
approved these changes
Mar 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
SquallATF
pushed a commit
to SquallATF/llvm-project
that referenced
this pull request
Mar 10, 2025
SquallATF
pushed a commit
to SquallATF/llvm-project
that referenced
this pull request
Mar 20, 2025
jph-13
pushed a commit
to jph-13/llvm-project
that referenced
this pull request
Mar 21, 2025
SquallATF
pushed a commit
to SquallATF/llvm-project
that referenced
this pull request
Apr 2, 2025
SquallATF
pushed a commit
to SquallATF/llvm-project
that referenced
this pull request
Apr 17, 2025
SquallATF
pushed a commit
to SquallATF/llvm-project
that referenced
this pull request
Apr 30, 2025
SquallATF
pushed a commit
to SquallATF/llvm-project
that referenced
this pull request
May 15, 2025
SquallATF
pushed a commit
to SquallATF/llvm-project
that referenced
this pull request
May 29, 2025
SquallATF
pushed a commit
to SquallATF/llvm-project
that referenced
this pull request
Jun 13, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.