[PATCH] D114275: [lld-macho] Include Objective-C functions in LC_FUNCTION_STARTS
Keith Smiley via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 19 12:55:00 PST 2021
keith created this revision.
Herald added a project: lld-macho.
Herald added a reviewer: lld-macho.
keith requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Previously since Objective-C functions aren't included in the symtab
they were also excluded from the function starts data. This degraded
the debugger experience in the case you didn't have debug info for for
some Objective-C code.
I'm not convinced this is the right way to do this, I'd love feedback!
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D114275
Files:
lld/MachO/SyntheticSections.cpp
lld/test/MachO/function-starts.s
Index: lld/test/MachO/function-starts.s
===================================================================
--- lld/test/MachO/function-starts.s
+++ lld/test/MachO/function-starts.s
@@ -41,6 +41,19 @@
# RUN: llvm-objdump --macho --function-starts %t/basic >> %t/objdump
# RUN: FileCheck %s --check-prefix=BASIC < %t/objdump
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/objc.s -o %t/objc.o
+# RUN: %lld -lSystem %t/objc.o -o %t/objc
+# RUN: llvm-objdump --syms %t/objc > %t/objdump
+# RUN: llvm-objdump --macho --function-starts %t/objc >> %t/objdump
+# RUN: FileCheck %s --check-prefix=OBJC < %t/objdump
+
+# OBJC-LABEL: SYMBOL TABLE:
+# OBJC-NEXT: [[#%x,F1:]] l F __TEXT,__text +[Foo bar]
+# OBJC-NEXT: [[#%x,F2:]] g F __TEXT,__text _main
+# OBJC-LABEL: objc:
+# OBJC: [[#F1]]
+# OBJC: [[#F2]]
+
#--- basic.s
.section __TEXT,__text,regular,pure_instructions
.globl _f1
@@ -62,3 +75,12 @@
retq
_main:
retq
+
+#--- objc.s
+.section __TEXT,__text
+"+[Foo bar]":
+ retq
+
+.globl _main
+_main:
+ retq
Index: lld/MachO/SyntheticSections.cpp
===================================================================
--- lld/MachO/SyntheticSections.cpp
+++ lld/MachO/SyntheticSections.cpp
@@ -796,16 +796,25 @@
void FunctionStartsSection::finalizeContents() {
raw_svector_ostream os{contents};
std::vector<uint64_t> addrs;
- for (const Symbol *sym : symtab->getSymbols()) {
- if (const auto *defined = dyn_cast<Defined>(sym)) {
- if (!defined->isec || !isCodeSection(defined->isec) || !defined->isLive())
- continue;
- if (const auto *concatIsec = dyn_cast<ConcatInputSection>(defined->isec))
- if (concatIsec->shouldOmitFromOutput())
+
+ for (const InputFile *file : inputFiles) {
+ if (auto *objFile = dyn_cast<ObjFile>(file)) {
+ for (const Symbol *sym : objFile->symbols) {
+ if (!sym)
continue;
- // TODO: Add support for thumbs, in that case
- // the lowest bit of nextAddr needs to be set to 1.
- addrs.push_back(defined->getVA());
+ if (const auto *defined = dyn_cast<Defined>(sym)) {
+ if (!defined->isec || !isCodeSection(defined->isec) ||
+ !defined->isLive())
+ continue;
+ if (const auto *concatIsec =
+ dyn_cast<ConcatInputSection>(defined->isec))
+ if (concatIsec->shouldOmitFromOutput())
+ continue;
+ // TODO: Add support for thumbs, in that case
+ // the lowest bit of nextAddr needs to be set to 1.
+ addrs.push_back(defined->getVA());
+ }
+ }
}
}
llvm::sort(addrs);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114275.388604.patch
Type: text/x-patch
Size: 2639 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211119/b6e1652b/attachment.bin>
More information about the llvm-commits
mailing list