[llvm] a0162a8 - [JITLink][MachO/x86_64] Expose API for creating eh-frame fixing passes.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Tue May 11 15:26:27 PDT 2021


Author: Lang Hames
Date: 2021-05-11T15:26:16-07:00
New Revision: a0162a81b1377331c3e0ebb58ac349b2ffd7b598

URL: https://github.com/llvm/llvm-project/commit/a0162a81b1377331c3e0ebb58ac349b2ffd7b598
DIFF: https://github.com/llvm/llvm-project/commit/a0162a81b1377331c3e0ebb58ac349b2ffd7b598.diff

LOG: [JITLink][MachO/x86_64] Expose API for creating eh-frame fixing passes.

These can be used to create eh-frame section fixing passes outside the usual
linker pipeline, which can be useful for tests and tools that just want to
verify or dump graphs.

Added: 
    

Modified: 
    llvm/include/llvm/ExecutionEngine/JITLink/MachO_x86_64.h
    llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ExecutionEngine/JITLink/MachO_x86_64.h b/llvm/include/llvm/ExecutionEngine/JITLink/MachO_x86_64.h
index 09a39bfcbd2e..6aee8c354f91 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/MachO_x86_64.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/MachO_x86_64.h
@@ -38,6 +38,14 @@ createLinkGraphFromMachOObject_x86_64(MemoryBufferRef ObjectBuffer);
 void link_MachO_x86_64(std::unique_ptr<LinkGraph> G,
                        std::unique_ptr<JITLinkContext> Ctx);
 
+/// Returns a pass suitable for splitting __eh_frame sections in MachO/x86-64
+/// objects.
+LinkGraphPassFunction createEHFrameSplitterPass_MachO_x86_64();
+
+/// Returns a pass suitable for fixing missing edges in an __eh_frame section
+/// in a MachO/x86-64 object.
+LinkGraphPassFunction createEHFrameEdgeFixerPass_MachO_x86_64();
+
 } // end namespace jitlink
 } // end namespace llvm
 

diff  --git a/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
index 7d7c0fd0891f..9e9b71d31049 100644
--- a/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
@@ -598,11 +598,8 @@ void link_MachO_x86_64(std::unique_ptr<LinkGraph> G,
 
   if (Ctx->shouldAddDefaultTargetPasses(G->getTargetTriple())) {
     // Add eh-frame passses.
-    StringRef EHFrameSectionName = "__TEXT,__eh_frame";
-    Config.PrePrunePasses.push_back(EHFrameSplitter(EHFrameSectionName));
-    Config.PrePrunePasses.push_back(
-        EHFrameEdgeFixer(EHFrameSectionName, G->getPointerSize(),
-                         x86_64::Delta64, x86_64::Delta32, x86_64::NegDelta32));
+    Config.PrePrunePasses.push_back(createEHFrameSplitterPass_MachO_x86_64());
+    Config.PrePrunePasses.push_back(createEHFrameEdgeFixerPass_MachO_x86_64());
 
     // Add a mark-live pass.
     if (auto MarkLive = Ctx->getMarkLivePass(G->getTargetTriple()))
@@ -625,5 +622,14 @@ void link_MachO_x86_64(std::unique_ptr<LinkGraph> G,
   MachOJITLinker_x86_64::link(std::move(Ctx), std::move(G), std::move(Config));
 }
 
+LinkGraphPassFunction createEHFrameSplitterPass_MachO_x86_64() {
+  return EHFrameSplitter("__TEXT,__eh_frame");
+}
+
+LinkGraphPassFunction createEHFrameEdgeFixerPass_MachO_x86_64() {
+  return EHFrameEdgeFixer("__TEXT,__eh_frame", x86_64::PointerSize,
+                          x86_64::Delta64, x86_64::Delta32, x86_64::NegDelta32);
+}
+
 } // end namespace jitlink
 } // end namespace llvm


        


More information about the llvm-commits mailing list