[PATCH] D114397: [lld-macho] Mark dylib symbols coming from -weak_framework as weak-def.
Vy Nguyen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 24 10:23:24 PST 2021
oontvoo updated this revision to Diff 389538.
oontvoo marked 4 inline comments as done.
oontvoo added a comment.
updated diff
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114397/new/
https://reviews.llvm.org/D114397
Files:
lld/MachO/Symbols.h
lld/test/MachO/weak-import.s
Index: lld/test/MachO/weak-import.s
===================================================================
--- lld/test/MachO/weak-import.s
+++ lld/test/MachO/weak-import.s
@@ -9,12 +9,12 @@
# RUN: %lld -lSystem -dylib %t/bar.o -o %t/libbar.dylib
# RUN: %lld -lSystem -dylib %t/foo.o %t/libbar.dylib -sub_library libbar -o %t/libfoo.dylib
-# RUN: %lld -weak-lSystem %t/test.o -weak_framework CoreFoundation -weak_library %t/libfoo.dylib -o %t/test
-# RUN: llvm-objdump --macho --all-headers %t/test | FileCheck %s -DDIR=%t --check-prefixes=WEAK-SYS,WEAK-FOO
+# RUN: %lld -weak-lSystem %t/test.o -weak_framework CoreFoundation -weak_library %t/libfoo.dylib -o %t/basic
+# RUN: llvm-objdump --macho --all-headers %t/basic | FileCheck %s -DDIR=%t --check-prefixes=WEAK-SYS,WEAK-FOO
# RUN: %lld -weak-lSystem %t/test.o \
# RUN: -framework CoreFoundation -weak_framework CoreFoundation -framework CoreFoundation \
-# RUN: %t/libfoo.dylib -weak_library %t/libfoo.dylib %t/libfoo.dylib -o %t/test
-# RUN: llvm-objdump --macho --all-headers %t/test | FileCheck %s -DDIR=%t --check-prefixes=WEAK-SYS,WEAK-FOO
+# RUN: %t/libfoo.dylib -weak_library %t/libfoo.dylib %t/libfoo.dylib -o %t/basic-weak-strong
+# RUN: llvm-objdump --macho --all-headers %t/basic-weak-strong | FileCheck %s -DDIR=%t --check-prefixes=WEAK-SYS,WEAK-FOO
# RUN: %lld -lSystem -dylib %t/libfoo.dylib %t/weak-ref-only.o -o %t/weak-ref-only
# RUN: llvm-objdump --macho --all-headers %t/weak-ref-only | FileCheck %s -DDIR=%t --check-prefixes=SYS,WEAK-FOO
# RUN: %lld -lSystem -dylib %t/libfoo.dylib %t/weak-ref-sub-library.o -o %t/weak-ref-sub-library
@@ -22,6 +22,10 @@
# RUN: %lld -lSystem -dylib %t/libfoo.dylib %t/mixed-ref.o -o %t/mixed-ref
# RUN: llvm-objdump --macho --all-headers %t/mixed-ref | FileCheck %s -DDIR=%t --check-prefixes=SYS,FOO
+# RUN: %lld -framework CoreFoundation %t/test.o -weak_framework CoreFoundation -o %t/strong-weak-import.out
+# RUN: llvm-objdump --macho --bind %t/strong-weak-import.out | FileCheck %s --check-prefix=WEAK-IMP
+# RUN: llvm-objdump --macho --bind %t/basic-weak-strong | FileCheck %s --check-prefix=WEAK-IMP
+
# WEAK-SYS: cmd LC_LOAD_WEAK_DYLIB
# WEAK-SYS-NEXT: cmdsize
# WEAK-SYS-NEXT: name /usr/lib/libSystem.dylib
@@ -42,6 +46,7 @@
# FOO-NEXT: cmdsize
# FOO-NEXT: name [[DIR]]/libfoo.dylib
+# WEAK-IMP: {{.+}} pointer 0 CoreFoundation __CFBigNumGetInt128 (weak_import)
#--- foo.s
.globl _foo
_foo:
@@ -69,4 +74,5 @@
#--- test.s
.globl _main
_main:
+ movq __CFBigNumGetInt128 at GOTPCREL(%rip), %rax
ret
Index: lld/MachO/Symbols.h
===================================================================
--- lld/MachO/Symbols.h
+++ lld/MachO/Symbols.h
@@ -235,8 +235,13 @@
}
uint64_t getVA() const override;
- bool isWeakDef() const override { return weakDef; }
- bool isWeakRef() const override { return refState == RefState::Weak; }
+ bool isWeakDef() const override {
+ return weakDef || (file && getFile()->umbrella->forceWeakImport);
+ }
+ bool isWeakRef() const override {
+ return refState == RefState::Weak ||
+ (file && getFile()->umbrella->forceWeakImport);
+ }
bool isReferenced() const { return refState != RefState::Unreferenced; }
bool isTlv() const override { return tlv; }
bool isDynamicLookup() const { return file == nullptr; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114397.389538.patch
Type: text/x-patch
Size: 3361 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211124/96ef7fc3/attachment.bin>
More information about the llvm-commits
mailing list