[PATCH] D106552: [lld/mac] Move handling of special undefineds later

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 22 08:44:21 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9d43c000e1b8: [lld/mac] Move handling of special undefineds later (authored by thakis).
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106552/new/

https://reviews.llvm.org/D106552

Files:
  lld/MachO/Driver.cpp
  lld/MachO/Writer.cpp


Index: lld/MachO/Writer.cpp
===================================================================
--- lld/MachO/Writer.cpp
+++ lld/MachO/Writer.cpp
@@ -47,6 +47,7 @@
 public:
   Writer() : buffer(errorHandler().outputBuffer) {}
 
+  void treatSpecialUndefineds();
   void scanRelocations();
   void scanSymbols();
   template <class LP> void createOutputSections();
@@ -550,6 +551,27 @@
 
 } // namespace
 
+void Writer::treatSpecialUndefineds() {
+  if (config->entry)
+    if (auto *undefined = dyn_cast<Undefined>(config->entry))
+      treatUndefinedSymbol(*undefined, "the entry point");
+
+  // FIXME: This prints symbols that are undefined both in input files and
+  // via -u flag twice.
+  for (const Symbol *sym : config->explicitUndefineds) {
+    if (const auto *undefined = dyn_cast<Undefined>(sym))
+      treatUndefinedSymbol(*undefined, "-u");
+  }
+  // Literal exported-symbol names must be defined, but glob
+  // patterns need not match.
+  for (const CachedHashStringRef &cachedName :
+       config->exportedSymbols.literals) {
+    if (const Symbol *sym = symtab->find(cachedName))
+      if (const auto *undefined = dyn_cast<Undefined>(sym))
+        treatUndefinedSymbol(*undefined, "-exported_symbol(s_list)");
+  }
+}
+
 // Add stubs and bindings where necessary (e.g. if the symbol is a
 // DylibSymbol.)
 static void prepareBranchTarget(Symbol *sym) {
@@ -1066,6 +1088,7 @@
 }
 
 template <class LP> void Writer::run() {
+  treatSpecialUndefineds();
   if (config->entry && !isa<Undefined>(config->entry))
     prepareBranchTarget(config->entry);
   scanRelocations();
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -1419,25 +1419,6 @@
     if (!orderFile.empty())
       parseOrderFile(orderFile);
 
-    if (config->entry)
-      if (auto *undefined = dyn_cast<Undefined>(config->entry))
-        treatUndefinedSymbol(*undefined, "the entry point");
-
-    // FIXME: This prints symbols that are undefined both in input files and
-    // via -u flag twice.
-    for (const Symbol *sym : config->explicitUndefineds) {
-      if (const auto *undefined = dyn_cast<Undefined>(sym))
-        treatUndefinedSymbol(*undefined, "-u");
-    }
-    // Literal exported-symbol names must be defined, but glob
-    // patterns need not match.
-    for (const CachedHashStringRef &cachedName :
-         config->exportedSymbols.literals) {
-      if (const Symbol *sym = symtab->find(cachedName))
-        if (const auto *undefined = dyn_cast<Undefined>(sym))
-          treatUndefinedSymbol(*undefined, "-exported_symbol(s_list)");
-    }
-
     referenceStubBinder();
 
     // FIXME: should terminate the link early based on errors encountered so


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106552.360839.patch
Type: text/x-patch
Size: 2768 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210722/a10a38d6/attachment.bin>


More information about the llvm-commits mailing list