[PATCH] D129062: [lld-macho] Handle user-provided dtrace symbols to avoid linking failure
Kaining Zhong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 4 00:55:26 PDT 2022
PRESIDENT810 created this revision.
PRESIDENT810 added reviewers: int3, gkm, oontvoo.
Herald added a subscriber: mgorny.
Herald added projects: lld-macho, All.
Herald added a reviewer: lld-macho.
PRESIDENT810 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This fixes https://github.com/llvm/llvm-project/issues/56238. ld64.lld currently does not generate __dof section in Mach-O, and -no_dtrace_dof option is on by default. However when there are user-defined dtrace symbols, ld64.lld will treat them as undefined symbols, which causes the linking to fail because lld cannot find their definitions. This patch allows ld64.lld to rewrite the instructions calling dtrace symbols to instructions like nop as what ld64 does; therefore, when encountered with user-provided dtrace probes, the linking can still succeed.
I'm not sure whether support for dtrace is expected in lld, so for now I didn't add codes to make lld emit __dof section like ld64, and only made it possible to link with dtrace symbols provided. If this feature is needed, I can add that part in Dtrace.cpp & Dtrace.h.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D129062
Files:
lld/MachO/Arch/ARM.cpp
lld/MachO/Arch/ARM64Common.cpp
lld/MachO/Arch/ARM64Common.h
lld/MachO/Arch/X86_64.cpp
lld/MachO/CMakeLists.txt
lld/MachO/Dtrace.cpp
lld/MachO/Dtrace.h
lld/MachO/InputFiles.cpp
lld/MachO/InputSection.cpp
lld/MachO/SymbolTable.cpp
lld/MachO/Target.h
lld/test/MachO/arm-dtrace.ll
lld/test/MachO/arm64-32-dtrace.ll
lld/test/MachO/arm64-dtrace.ll
lld/test/MachO/x86_64-dtrace.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129062.442020.patch
Type: text/x-patch
Size: 22197 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220704/6381c0f6/attachment-0001.bin>
More information about the llvm-commits
mailing list