[PATCH] D97007: [lld-macho] Define __mh_bundle_header as symbol (similar to ___dso_handle)

Vy Nguyen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 18 15:46:08 PST 2021


oontvoo created this revision.
oontvoo added a reviewer: int3.
Herald added a project: lld-macho.
Herald added a reviewer: lld-macho.
oontvoo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Outstanding issue: Both __mh_bundle_header and ___dso_handle need to present in a bundle, but neither of these is actually used right now?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97007

Files:
  lld/MachO/Symbols.cpp
  lld/MachO/Symbols.h


Index: lld/MachO/Symbols.h
===================================================================
--- lld/MachO/Symbols.h
+++ lld/MachO/Symbols.h
@@ -40,6 +40,7 @@
     DylibKind,
     LazyKind,
     DSOHandleKind,
+    MHBundleHeaderKind,
   };
 
   virtual ~Symbol() {}
@@ -254,6 +255,27 @@
   static bool classof(const Symbol *s) { return s->kind() == DSOHandleKind; }
 };
 
+class MHBundleHeader : public Symbol {
+public:
+  MHBundleHeader(const MachHeaderSection *header)
+      : Symbol(MHBundleHeaderKind, name, nullptr), header(header) {}
+  const MachHeaderSection *header;
+
+  uint64_t getVA() const override;
+
+  uint64_t getFileOffset() const override;
+
+  bool isWeakDef() const override { return false; }
+
+  bool isTlv() const override { return false; }
+
+  static constexpr StringRef name = "__mh_bundle_header";
+
+  static bool classof(const Symbol *s) {
+    return s->kind() == MHBundleHeaderKind;
+  }
+};
+
 union SymbolUnion {
   alignas(Defined) char a[sizeof(Defined)];
   alignas(Undefined) char b[sizeof(Undefined)];
@@ -261,6 +283,7 @@
   alignas(DylibSymbol) char d[sizeof(DylibSymbol)];
   alignas(LazySymbol) char e[sizeof(LazySymbol)];
   alignas(DSOHandle) char f[sizeof(DSOHandle)];
+  alignas(MHBundleHeader) char g[sizeof(MHBundleHeader)];
 };
 
 template <typename T, typename... ArgT>
Index: lld/MachO/Symbols.cpp
===================================================================
--- lld/MachO/Symbols.cpp
+++ lld/MachO/Symbols.cpp
@@ -51,3 +51,9 @@
 uint64_t DSOHandle::getFileOffset() const { return header->fileOff; }
 
 constexpr StringRef DSOHandle::name;
+
+uint64_t MHBundleHeader::getVA() const { return header->addr; }
+
+uint64_t MHBundleHeader::getFileOffset() const { return header->fileOff; }
+
+constexpr StringRef MHBundleHeader::name;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97007.324798.patch
Type: text/x-patch
Size: 1794 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210218/5239aa42/attachment.bin>


More information about the llvm-commits mailing list