[lld] 1b2d84a - [lld-macho][test] Check addresses in flat-namespace-interposable.s
Daniel Bertalan via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 24 14:50:57 PDT 2022
Author: Daniel Bertalan
Date: 2022-08-24T23:49:50+02:00
New Revision: 1b2d84a55311bc58c8ae8c039703ecc5ab4b0eb4
URL: https://github.com/llvm/llvm-project/commit/1b2d84a55311bc58c8ae8c039703ecc5ab4b0eb4
DIFF: https://github.com/llvm/llvm-project/commit/1b2d84a55311bc58c8ae8c039703ecc5ab4b0eb4.diff
LOG: [lld-macho][test] Check addresses in flat-namespace-interposable.s
This test helped me catch an issue in my implementation of chained
fixups (D132560). This commit makes the test more robust by checking if
the bind opcodes are emitted for the correct address.
Differential Revision: https://reviews.llvm.org/D132367
Added:
Modified:
lld/test/MachO/flat-namespace-interposable.s
Removed:
################################################################################
diff --git a/lld/test/MachO/flat-namespace-interposable.s b/lld/test/MachO/flat-namespace-interposable.s
index e561f7b1c9be8..fb15d447a23c4 100644
--- a/lld/test/MachO/flat-namespace-interposable.s
+++ b/lld/test/MachO/flat-namespace-interposable.s
@@ -11,40 +11,63 @@
# RUN: %lld -lSystem -flat_namespace -o %t/foo %t/foo.o
# RUN: %lld -lSystem -dylib -flat_namespace -o %t/foo.dylib %t/foo.o
# RUN: %lld -lSystem -bundle -flat_namespace -o %t/foo.bundle %t/foo.o
-# RUN: llvm-objdump --macho --bind --lazy-bind --weak-bind %t/foo | FileCheck \
-# RUN: %s --check-prefix=EXEC --implicit-check-not=_private_extern
-# RUN: llvm-objdump --macho --bind --lazy-bind --weak-bind %t/foo.dylib | \
-# RUN: FileCheck %s --check-prefix=DYLIB --implicit-check-not=_private_extern
-# RUN: llvm-objdump --macho --bind --lazy-bind --weak-bind %t/foo.bundle | \
-# RUN: FileCheck %s --check-prefix=DYLIB --implicit-check-not=_private_extern
+# RUN: llvm-objdump --macho --syms --rebase --bind --lazy-bind --weak-bind %t/foo | \
+# RUN: FileCheck %s --check-prefixes=SYMS,EXEC --implicit-check-not=_private_extern
+# RUN: llvm-objdump --macho --syms --rebase --bind --lazy-bind --weak-bind %t/foo.dylib | \
+# RUN: FileCheck %s --check-prefixes=SYMS,DYLIB --implicit-check-not=_private_extern
+# RUN: llvm-objdump --macho --syms --rebase --bind --lazy-bind --weak-bind %t/foo.bundle | \
+# RUN: FileCheck %s --check-prefixes=SYMS,DYLIB --implicit-check-not=_private_extern
+
+# SYMS: SYMBOL TABLE:
+# SYMS-DAG: [[#%x, EXTERN_REF:]] l O __DATA,__data _extern_ref
+# SYMS-DAG: [[#%x, LOCAL_REF:]] l O __DATA,__data _local_ref
+# SYMS-DAG: [[#%x, WEAK_REF:]] l O __DATA,__data _weak_ref
+# SYMS-DAG: [[#%x, TLV_REF:]] g O __DATA,__thread_vars _tlv
## Executables with -flat_namespace don't have interposable externs.
-# EXEC: Bind table:
+# EXEC: Rebase table:
+# EXEC-NEXT: segment section address type
+# EXEC-DAG: __DATA __la_symbol_ptr 0x[[#%X, WEAK_LAZY:]] pointer
+# EXEC-DAG: __DATA __data 0x[[#%.8X, EXTERN_REF]] pointer
+# EXEC-DAG: __DATA __data 0x[[#%.8X, LOCAL_REF]] pointer
+# EXEC-DAG: __DATA __data 0x[[#%.8X, WEAK_REF]] pointer
+# EXEC-EMPTY:
+# EXEC-NEXT: Bind table:
# EXEC-NEXT: segment section address type addend dylib symbol
# EXEC-EMPTY:
# EXEC-NEXT: Lazy bind table:
# EXEC-NEXT: segment section address dylib symbol
# EXEC-EMPTY:
# EXEC-NEXT: Weak bind table:
-# EXEC-NEXT: segment section address type addend symbol
-# EXEC-NEXT: __DATA __la_symbol_ptr {{.*}} pointer 0 _weak_extern
-# EXEC-NEXT: __DATA __data {{.*}} pointer 0 _weak_extern
+# EXEC-NEXT: segment section address type addend symbol
+# EXEC-NEXT: __DATA __la_symbol_ptr 0x[[#%.8X, WEAK_LAZY]] pointer 0 _weak_extern
+# EXEC-NEXT: __DATA __data 0x[[#%.8X, WEAK_REF]] pointer 0 _weak_extern
# EXEC-EMPTY:
-# DYLIB: Bind table:
-# DYLIB-NEXT: segment section address type addend dylib symbol
-# DYLIB-DAG: __DATA __data {{.*}} pointer 0 flat-namespace _extern
-# DYLIB-DAG: __DATA __thread_ptrs {{.*}} pointer 0 flat-namespace _tlv
-# DYLIB-DAG: __DATA_CONST __got {{.*}} pointer 0 flat-namespace dyld_stub_binder
+# DYLIB: Rebase table:
+# DYLIB-NEXT: segment section address type
+# DYLIB-DAG: __DATA __la_symbol_ptr 0x[[#%X, WEAK_LAZY:]] pointer
+# DYLIB-DAG: __DATA __la_symbol_ptr 0x[[#%X, EXTERN_LAZY:]] pointer
+# DYLIB-DAG: __DATA __data 0x[[#%.8X, EXTERN_REF]] pointer
+# DYLIB-DAG: __DATA __data 0x[[#%.8X, LOCAL_REF]] pointer
+# DYLIB-DAG: __DATA __data 0x[[#%.8X, WEAK_REF]] pointer
+# DYLIB-DAG: __DATA __thread_ptrs 0x[[#%.8X, TLV_REF]] pointer
+# DYLIB-EMPTY:
+# DYLIB-NEXT: Bind table:
+# DYLIB-NEXT: segment section address type addend dylib symbol
+# DYLIB-DAG: __DATA_CONST __got {{.*}} pointer 0 flat-namespace dyld_stub_binder
+# DYLIB-DAG: __DATA __data 0x[[#%.8X, EXTERN_REF]] pointer 0 flat-namespace _extern
+# DYLIB-DAG: __DATA __thread_ptrs 0x[[#%.8X, TLV_REF]] pointer 0 flat-namespace _tlv
# DYLIB-EMPTY:
# DYLIB-NEXT: Lazy bind table:
-# DYLIB-NEXT: segment section address dylib symbol
-# DYLIB-NEXT: __DATA __la_symbol_ptr {{.*}} flat-namespace _extern
+# DYLIB-NEXT: segment section address dylib symbol
+# DYLIB-NEXT: __DATA __la_symbol_ptr 0x[[#%.8X, EXTERN_LAZY]] flat-namespace _extern
# DYLIB-EMPTY:
# DYLIB-NEXT: Weak bind table:
-# DYLIB-NEXT: segment section address type addend symbol
-# DYLIB-NEXT: __DATA __la_symbol_ptr {{.*}} pointer 0 _weak_extern
-# DYLIB-NEXT: __DATA __data {{.*}} pointer 0 _weak_extern
+# DYLIB-NEXT: segment section address type addend symbol
+# DYLIB-NEXT: __DATA __la_symbol_ptr 0x[[#%.8X, WEAK_LAZY]] pointer 0 _weak_extern
+# DYLIB-NEXT: __DATA __data 0x[[#%.8X, WEAK_REF]] pointer 0 _weak_extern
+# DYLIB-EMPTY:
#--- foo.s
@@ -70,8 +93,11 @@ _main:
retq
.data
+_extern_ref:
.quad _extern
+_weak_ref:
.quad _weak_extern
+_local_ref:
.quad _local
.section __DATA,__thread_vars,thread_local_variables
More information about the llvm-commits
mailing list