[PATCH] D141082: [lld] Prevent assertions for aliases to weak_def_can_be_hidden symbols

Paul Kirth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 5 15:35:17 PST 2023


paulkirth updated this revision to Diff 486697.
paulkirth added a comment.

Remove newlines in test file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141082

Files:
  lld/MachO/InputFiles.cpp
  lld/test/MachO/weak-def-can-be-hidden.s


Index: lld/test/MachO/weak-def-can-be-hidden.s
===================================================================
--- lld/test/MachO/weak-def-can-be-hidden.s
+++ lld/test/MachO/weak-def-can-be-hidden.s
@@ -116,6 +116,9 @@
 _foo:
   retq
 
+# A private alias to a weak_def_can_be_hidden symbol should not raise an error or assertion
+.set l_foo, _foo
+
 #--- weak-foo-pe.s
 .private_extern _foo
 .globl _foo
Index: lld/MachO/InputFiles.cpp
===================================================================
--- lld/MachO/InputFiles.cpp
+++ lld/MachO/InputFiles.cpp
@@ -698,7 +698,10 @@
         sym.n_desc & REFERENCED_DYNAMICALLY, sym.n_desc & N_NO_DEAD_STRIP,
         isWeakDefCanBeHidden);
   }
-  assert(!isWeakDefCanBeHidden &&
+  // weak_def_can_be_hidden symbols should not reach this point, however a
+  // private alias to one can, so only assert if a weak_def_can_be_hidden symbol
+  // reaches this point, which is not an alias.
+  assert((!isWeakDefCanBeHidden || sym.n_type & N_INDR) &&
          "weak_def_can_be_hidden on already-hidden symbol?");
   bool includeInSymtab = !isPrivateLabel(name) && !isEhFrameSection(isec);
   return make<Defined>(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141082.486697.patch
Type: text/x-patch
Size: 1166 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230105/d165bfd2/attachment.bin>


More information about the llvm-commits mailing list