[lld] eb4a517 - Revert "[lld-macho] Fix assertion failure in registerCompactUnwind"

Vy Nguyen via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 9 07:32:15 PST 2021


Author: Vy Nguyen
Date: 2021-11-09T10:31:47-05:00
New Revision: eb4a5178161d2a41d267d4b23628dc6f8a124fba

URL: https://github.com/llvm/llvm-project/commit/eb4a5178161d2a41d267d4b23628dc6f8a124fba
DIFF: https://github.com/llvm/llvm-project/commit/eb4a5178161d2a41d267d4b23628dc6f8a124fba.diff

LOG: Revert "[lld-macho] Fix assertion failure in registerCompactUnwind"

broke windows build - reverting to investigate
This reverts commit b2d92584742e333799ed6a3687c801dde9bb6174.

Added: 
    

Modified: 
    lld/MachO/SymbolTable.cpp
    lld/test/MachO/weak-definition-gc.s

Removed: 
    


################################################################################
diff  --git a/lld/MachO/SymbolTable.cpp b/lld/MachO/SymbolTable.cpp
index df7237468ae3d..37c3fe0d38c74 100644
--- a/lld/MachO/SymbolTable.cpp
+++ b/lld/MachO/SymbolTable.cpp
@@ -62,32 +62,28 @@ Defined *SymbolTable::addDefined(StringRef name, InputFile *file,
   if (!wasInserted) {
     if (auto *defined = dyn_cast<Defined>(s)) {
       if (isWeakDef) {
-
-        // See further comment in createDefined() in InputFiles.cpp
         if (defined->isWeakDef()) {
+          // Both old and new symbol weak (e.g. inline function in two TUs):
+          // If one of them isn't private extern, the merged symbol isn't.
           defined->privateExtern &= isPrivateExtern;
           defined->referencedDynamically |= isReferencedDynamically;
           defined->noDeadStrip |= noDeadStrip;
+
+          // FIXME: Handle this for bitcode files.
+          // FIXME: We currently only do this if both symbols are weak.
+          //        We could do this if either is weak (but getting the
+          //        case where !isWeakDef && defined->isWeakDef() right
+          //        requires some care and testing).
+          if (auto concatIsec = dyn_cast_or_null<ConcatInputSection>(isec))
+            concatIsec->wasCoalesced = true;
         }
-        // FIXME: Handle this for bitcode files.
-        if (auto concatIsec = dyn_cast_or_null<ConcatInputSection>(isec))
-          concatIsec->wasCoalesced = true;
+
         return defined;
       }
-
-      if (defined->isWeakDef()) {
-        // FIXME: Handle this for bitcode files.
-        if (auto concatIsec =
-                dyn_cast_or_null<ConcatInputSection>(defined->isec)) {
-          concatIsec->wasCoalesced = true;
-          concatIsec->symbols.erase(llvm::find(concatIsec->symbols, defined));
-        }
-      } else {
+      if (!defined->isWeakDef())
         error("duplicate symbol: " + name + "\n>>> defined in " +
               toString(defined->getFile()) + "\n>>> defined in " +
               toString(file));
-      }
-
     } else if (auto *dysym = dyn_cast<DylibSymbol>(s)) {
       overridesWeakDef = !isWeakDef && dysym->isWeakDef();
       dysym->unreference();

diff  --git a/lld/test/MachO/weak-definition-gc.s b/lld/test/MachO/weak-definition-gc.s
index 7ba2eb18ddcab..0660ccc524d42 100644
--- a/lld/test/MachO/weak-definition-gc.s
+++ b/lld/test/MachO/weak-definition-gc.s
@@ -66,25 +66,6 @@
 # ALIGN-NEXT: {{0*}}[[#ADDR]]      11111111 33333333 22222222 00000000
 # ALIGN-NEXT: {{0*}}[[#ADDR+0x10]] 81818181 81818181 82828282 82828282
 
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/weak-def.s -o %t/weak-def.o
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/strong-def.s -o %t/strong-def.o
-# RUN: %lld -dylib -lc++ -o %t/weak-strong-mixed.dylib %t/weak-def.o %t/strong-def.o
-# RUN: %lld -dylib -lc++ -o %t/strong-weak-mixed.dylib %t/strong-def.o %t/weak-def.o
-## Check that omitted weak symbols are not adding their section and unwind stuff.
-
-# RUN: otool -jtV %t/weak-strong-mixed.dylib | FileCheck --check-prefix=MIXED %s
-# RUN: otool -jtV %t/strong-weak-mixed.dylib | FileCheck --check-prefix=MIXED %s
-# MIXED: (__TEXT,__text) section
-# MIXED-NEXT: _foo:
-# MIXED-NEXT: {{.+}} 	3333            	xorl	(%rbx), %esi
-# MIXED-NEXT: {{.+}} 	3333            	xorl	(%rbx), %esi
-# MIXED-NEXT: {{.+}}	c3              	retq
-
-# RUN: llvm-objdump --macho --syms --unwind-info %t/weak-strong-mixed.dylib | FileCheck --check-prefix=MIXED-UNWIND %s
-# RUN: llvm-objdump --macho --syms --unwind-info %t/strong-weak-mixed.dylib | FileCheck --check-prefix=MIXED-UNWIND %s
-# MIXED-UNWIND: g     F __TEXT,__text _foo
-# MIXED-UNWIND-NOT: Contents of __unwind_info section:
-
 #--- weak-sub.s
 .globl _foo, _bar
 .weak_definition _foo, _bar
@@ -214,35 +195,3 @@ _main:
   retq
 
 .subsections_via_symbols
-
-#--- weak-def.s
-.section __TEXT,__text,regular,pure_instructions
-
-.globl _foo
-.weak_definition _foo
-_foo:
-  .cfi_startproc
-  .cfi_personality 155, ___gxx_personality_v0
-  .cfi_lsda 16, Lexception
-  pushq %rbp
-  .cfi_def_cfa_offset 128
-  .cfi_offset %rbp, 48
-  movq %rsp, %rbp
-  .cfi_def_cfa_register %rbp
-  popq %rbp
-  retq
-  .cfi_endproc
-
-.section __TEXT,__gcc_except_tab
-Lexception:
-    .space 0x10
-
-.subsections_via_symbols
-#--- strong-def.s
-.globl _foo, _bar
-
-_foo:
-  .4byte 0x33333333
-  retq
-
-.subsections_via_symbols


        


More information about the llvm-commits mailing list