[PATCH] D101223: [lld/mac] Don't assert when using -exported_symbol with private symbol

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 24 07:22:14 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGde266ce4f9f2: [lld/mac] Don't assert when using -exported_symbol with private symbol (authored by thakis).
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101223

Files:
  lld/MachO/SyntheticSections.cpp
  lld/test/MachO/export-options.s


Index: lld/test/MachO/export-options.s
===================================================================
--- lld/test/MachO/export-options.s
+++ lld/test/MachO/export-options.s
@@ -38,6 +38,8 @@
 .private_extern _private_extern
 _private_extern:
   retq
+_private:
+  retq
 
 ## Check that the export trie is unaltered
 # RUN: %lld -dylib %t/default.o -o %t/default
Index: lld/MachO/SyntheticSections.cpp
===================================================================
--- lld/MachO/SyntheticSections.cpp
+++ lld/MachO/SyntheticSections.cpp
@@ -585,8 +585,10 @@
 }
 
 static bool shouldExportSymbol(const Defined *defined) {
-  if (defined->privateExtern)
+  if (defined->privateExtern) {
+    assert(defined->isExternal() && "invalid input file");
     return false;
+  }
   // TODO: Is this a performance bottleneck? If a build has mostly
   // global symbols in the input but uses -exported_symbols to filter
   // out most of them, then it would be better to set the value of
@@ -844,7 +846,6 @@
       if (!shouldExportSymbol(defined)) {
         // Private external -- dylib scoped symbol.
         // Promote to non-external at link time.
-        assert(defined->isExternal() && "invalid input file");
         scope = N_PEXT;
       } else if (defined->isExternal()) {
         // Normal global symbol.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101223.340276.patch
Type: text/x-patch
Size: 1318 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210424/68b64fc8/attachment.bin>


More information about the llvm-commits mailing list