107 lines · plain
1; REQUIRES: x862 3; RUN: rm -rf %t; split-file %s %t4 5; RUN: opt -module-summary %t/defined.ll -o %t/defined.o6; RUN: opt -module-summary %t/weak-defined.ll -o %t/weak-defined.o7; RUN: opt -module-summary %t/archive.ll -o %t/archive.o8; RUN: opt -module-summary %t/calls-foo.ll -o %t/calls-foo.o9; RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/weak-defined.s -o %t/weak-defined-asm.o10 11; RUN: %lld -lSystem -dylib %t/defined.o -o %t/libfoo.dylib12; RUN: %lld -lSystem -dylib %t/weak-defined.o -o %t/libweakfoo.dylib13 14; RUN: llvm-ar rcs %t/archive.a %t/archive.o15 16;; Regular defined symbols take precedence over weak ones.17; RUN: %lld -lSystem %t/defined.o %t/weak-defined.o %t/calls-foo.o -o %t/test18; RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=DEFINED19; RUN: %lld -lSystem %t/weak-defined.o %t/defined.o %t/calls-foo.o -o %t/test20; RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=DEFINED21 22;; Regular defined symbols take precedence over weak non-bitcode ones.23; RUN: %lld -lSystem %t/defined.o %t/weak-defined-asm.o %t/calls-foo.o -o %t/test24; RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=DEFINED25; RUN: %lld -lSystem %t/weak-defined-asm.o %t/defined.o %t/calls-foo.o -o %t/test26; RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=DEFINED27 28;; NOTE: we are deviating from ld64's behavior here.29;; ld64: Weak non-bitcode symbols take precedence over weak bitcode ones.30;; lld: Weak non-bitcode symbols have the same precedence as weak bitcode ones.31; RUN: %lld -lSystem %t/weak-defined.o %t/weak-defined-asm.o %t/calls-foo.o -o %t/test32; RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=WEAK-DEFINED33; COM (ld64): llvm-objdump --syms %t/test | FileCheck %s --check-prefix=WEAK-DEFINED-ASM34; RUN: %lld -lSystem %t/weak-defined-asm.o %t/weak-defined.o %t/calls-foo.o -o %t/test35; RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=WEAK-DEFINED-ASM36 37;; Weak defined symbols take precedence over dylib symbols.38; RUN: %lld -lSystem %t/weak-defined.o %t/libfoo.dylib %t/calls-foo.o -o %t/test39; RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=WEAK-DEFINED40; RUN: %lld -lSystem %t/libfoo.dylib %t/weak-defined.o %t/calls-foo.o -o %t/test41; RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=WEAK-DEFINED42 43;; Weak defined symbols take precedence over archive symbols.44; RUN: %lld -lSystem %t/archive.a %t/weak-defined.o %t/calls-foo.o -o %t/test45; RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=WEAK-DEFINED46; RUN: %lld -lSystem %t/weak-defined.o %t/archive.a %t/calls-foo.o -o %t/test47; RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=WEAK-DEFINED48 49;; Archive symbols have the same precedence as dylib symbols.50; RUN: %lld -lSystem %t/archive.a %t/libfoo.dylib %t/calls-foo.o -o %t/test51; RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=ARCHIVE52; RUN: %lld -lSystem %t/libfoo.dylib %t/archive.a %t/calls-foo.o -o %t/test53; RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=DYLIB54 55;; Archive symbols take precedence over weak dylib symbols.56; RUN: %lld -lSystem %t/archive.a %t/libweakfoo.dylib %t/calls-foo.o -o %t/test57; RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=ARCHIVE58; RUN: %lld -lSystem %t/libweakfoo.dylib %t/archive.a %t/calls-foo.o -o %t/test59; RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=ARCHIVE60 61; DEFINED: g O __TEXT,defined _foo62; WEAK-DEFINED: w O __TEXT,weak_defined _foo63; WEAK-DEFINED-ASM: w O __TEXT,weak_defined_asm _foo64; ARCHIVE: g O __TEXT,archive _foo65; DYLIB: *UND* _foo66 67;--- defined.ll68target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"69target triple = "x86_64-apple-macosx10.15.0"70 71define void @foo() section "__TEXT,defined" {72 ret void73}74 75;--- weak-defined.ll76target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"77target triple = "x86_64-apple-macosx10.15.0"78 79define weak void @foo() section "__TEXT,weak_defined" {80 ret void81}82 83;--- weak-defined.s84.globl _foo85.weak_definition _foo86.section __TEXT,weak_defined_asm87_foo:88 89;--- archive.ll90target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"91target triple = "x86_64-apple-macosx10.15.0"92 93define void @foo() section "__TEXT,archive" {94 ret void95}96 97;--- calls-foo.ll98target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"99target triple = "x86_64-apple-macosx10.15.0"100 101declare void @foo()102 103define void @main() {104 call void @foo()105 ret void106}107