[PATCH] D125732: [lld-macho] Demangle symbol name in export error msg when -demangle is specified

Vy Nguyen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 16 16:46:02 PDT 2022


oontvoo updated this revision to Diff 429896.
oontvoo added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125732

Files:
  lld/MachO/Driver.cpp
  lld/test/MachO/demangle.s


Index: lld/test/MachO/demangle.s
===================================================================
--- lld/test/MachO/demangle.s
+++ lld/test/MachO/demangle.s
@@ -1,15 +1,46 @@
 # REQUIRES: x86
 
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
+# RUN: rm -rf %t; split-file %s %t
 
-# RUN: not %lld %t.o -o /dev/null 2>&1 | FileCheck %s
-# RUN: not %lld -demangle %t.o -o /dev/null 2>&1 | \
-# RUN:     FileCheck --check-prefix=DEMANGLE %s
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/undefined-symbol.s -o %t/undefined-symbol.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/export-symbols.s -o %t/export-symbols.o
 
-# CHECK: undefined symbol: __Z1fv
-# DEMANGLE: undefined symbol: f()
+# RUN: not %lld %t/undefined-symbol.o -o /dev/null 2>&1 | FileCheck --check-prefix=UNDEF %s
+# RUN: not %lld -demangle %t/undefined-symbol.o -o /dev/null 2>&1 | \
+# RUN:     FileCheck --check-prefix=DEMANGLE-UNDEF %s
 
+# RUN: not %lld -exported_symbol __ZTIN3foo3bar4MethE -exported_symbol __ZTSN3foo3bar4MethE %t/export-symbols.o -o /dev/null 2>&1 | FileCheck --check-prefix=EXPORT %s
+# RUN: not %lld -demangle -exported_symbol __ZTIN3foo3bar4MethE -exported_symbol __ZTSN3foo3bar4MethE %t/export-symbols.o -o /dev/null 2>&1 | FileCheck --check-prefix=DEMANGLE-EXPORT %s
+
+# UNDEF: undefined symbol: __Z1fv
+# DEMANGLE-UNDEF: undefined symbol: f()
+
+# EXPORT: cannot export hidden symbol __ZTSN3foo3bar4MethE
+# EXPORT: cannot export hidden symbol __ZTIN3foo3bar4MethE
+
+# DEMANGLE-EXPORT: cannot export hidden symbol typeinfo name for foo::bar::Meth
+# DEMANGLE-EXPORT: cannot export hidden symbol typeinfo for foo::bar::Meth
+
+#--- undefined-symbol.s
 .globl _main
 _main:
   callq __Z1fv
   ret
+
+
+#--- export-symbols.s
+.globl _main
+_main:
+  ret
+
+.globl __ZTIN3foo3bar4MethE
+.weak_def_can_be_hidden __ZTIN3foo3bar4MethE
+.private_extern __ZTIN3foo3bar4MethE
+__ZTIN3foo3bar4MethE:
+  retq
+
+.globl __ZTSN3foo3bar4MethE
+.weak_def_can_be_hidden __ZTSN3foo3bar4MethE
+.private_extern __ZTSN3foo3bar4MethE
+__ZTSN3foo3bar4MethE:
+  retq
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -1519,7 +1519,7 @@
                 // The former can be exported but the latter cannot.
                 defined->privateExtern = false;
               } else {
-                warn("cannot export hidden symbol " + symbolName +
+                warn("cannot export hidden symbol " + toString(*defined) +
                      "\n>>> defined in " + toString(defined->getFile()));
               }
             }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125732.429896.patch
Type: text/x-patch
Size: 2658 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220516/3e6c2cd7/attachment.bin>


More information about the llvm-commits mailing list