Skip to content

Commit

Permalink
[lld] enable fixup chains by default
Browse files Browse the repository at this point in the history
  • Loading branch information
rmaz committed Jan 29, 2024
1 parent d133ada commit f35fa7d
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
3 changes: 1 addition & 2 deletions lld/MachO/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1075,8 +1075,7 @@ static bool shouldEmitChainedFixups(const InputArgList &args) {
return false;
}

// TODO: Enable by default once stable.
return isRequested;
return true;
}

void SymbolPatterns::clear() {
Expand Down
6 changes: 3 additions & 3 deletions lld/test/MachO/arm64-objc-stubs-dyn.s
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@
# CHECK-EMPTY:

# STUB: Contents of (__TEXT,__stubs) section
# STUB-NEXT: adrp x16, 8 ; 0x100008000
# STUB-NEXT: adrp x16, 4 ; 0x100004000
# STUB-NEXT: ldr x16, [x16]
# STUB-NEXT: br x16

# SMALL: Contents of (__TEXT,__objc_stubs) section
# SMALL-NEXT: _objc_msgSend$foo:
# SMALL-NEXT: adrp x1, 8 ; 0x100008000
# SMALL-NEXT: ldr x1, [x1, #0x18]
# SMALL-NEXT: ldr x1, [x1, #0x10]
# SMALL-NEXT: b
# SMALL-NEXT: _objc_msgSend$length:
# SMALL-NEXT: adrp x1, 8 ; 0x100008000
# SMALL-NEXT: ldr x1, [x1, #0x20]
# SMALL-NEXT: ldr x1, [x1, #0x18]
# SMALL-NEXT: b

.section __TEXT,__objc_methname,cstring_literals
Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/arm64-relocs.s
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# CHECK-NEXT: ret

# CHECK-LABEL: Contents of (__DATA_CONST,__const) section
# CHECK: [[#PTR_1]] {{0*}}[[#BAZ]] 00000000 00000000 00000000
# CHECK: [[#PTR_1]] {{0*}}[[#BAZ]] 00200000 00000000 00000000
# CHECK: [[#PTR_2]] {{0*}}[[#BAZ+123]] 00000000 00000000 00000000

.text
Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/arm64-stubs.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/test.s -o %t/test.o
# RUN: %lld -arch arm64 -dylib -install_name @executable_path/libfoo.dylib %t/foo.o -o %t/libfoo.dylib
# RUN: %lld -arch arm64 -dylib -install_name @executable_path/libbar.dylib %t/bar.o -o %t/libbar.dylib
# RUN: %lld -arch arm64 -lSystem %t/libfoo.dylib %t/libbar.dylib %t/test.o -o %t/test
# RUN: %lld -arch arm64 -lSystem %t/libfoo.dylib %t/libbar.dylib %t/test.o -o %t/test -no_fixup_chains

# RUN: llvm-objdump --no-print-imm-hex --macho -d --no-show-raw-insn --section="__TEXT,__stubs" --section="__TEXT,__stub_helper" %t/test | FileCheck %s

Expand Down
14 changes: 7 additions & 7 deletions lld/test/MachO/dyld-stub-binder.s
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@
# RUN: %lld -arch arm64 -lSystem -dylib %t/foo.o -o %t/libfoo.dylib
# RUN: llvm-nm -m %t/libfoo.dylib | FileCheck --check-prefix=STUB %s


## Dylibs that do lazy dynamic calls do need dyld_stub_binder.
# RUN: not %no-lsystem-lld -arch arm64 -dylib %t/bar.o %t/libfoo.dylib \
# RUN: -o %t/libbar.dylib 2>&1 | FileCheck --check-prefix=MISSINGSTUB %s
# RUN: -o %t/libbar.dylib -no_fixup_chains 2>&1 | \
# RUN: FileCheck --check-prefix=MISSINGSTUB %s
# RUN: %lld -arch arm64 -lSystem -dylib %t/bar.o %t/libfoo.dylib \
# RUN: -o %t/libbar.dylib
# RUN: -o %t/libbar.dylib -no_fixup_chains
# RUN: llvm-nm -m %t/libbar.dylib | FileCheck --check-prefix=STUB %s

## As do executables.
# RUN: not %no-lsystem-lld -arch arm64 %t/libfoo.dylib %t/libbar.dylib %t/test.o \
# RUN: -o %t/test 2>&1 | FileCheck --check-prefix=MISSINGSTUB %s
# RUN: -o %t/test -no_fixup_chains 2>&1 | FileCheck --check-prefix=MISSINGSTUB %s
# RUN: %lld -arch arm64 -lSystem %t/libfoo.dylib %t/libbar.dylib %t/test.o \
# RUN: -o %t/test
# RUN: -o %t/test -no_fixup_chains
# RUN: llvm-nm -m %t/test | FileCheck --check-prefix=STUB %s

## Test dynamic lookup of dyld_stub_binder.
# RUN: %no-lsystem-lld -arch arm64 %t/libfoo.dylib %t/libbar.dylib %t/test.o \
# RUN: -o %t/test -undefined dynamic_lookup
# RUN: -o %t/test -undefined dynamic_lookup -no_fixup_chains
# RUN: llvm-nm -m %t/test | FileCheck --check-prefix=DYNSTUB %s
# RUN: %no-lsystem-lld -arch arm64 %t/libfoo.dylib %t/libbar.dylib %t/test.o \
# RUN: -o %t/test -U dyld_stub_binder
# RUN: -o %t/test -U dyld_stub_binder -no_fixup_chains
# RUN: llvm-nm -m %t/test | FileCheck --check-prefix=DYNSTUB %s

# MISSINGSTUB: error: undefined symbol: dyld_stub_binder
Expand Down
8 changes: 4 additions & 4 deletions lld/test/MachO/icf-safe.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
; RUN: rm -rf %t; mkdir %t

; RUN: llc -filetype=obj %s -O3 -o %t/icf-obj.o -enable-machine-outliner=never -mtriple arm64-apple-macos -addrsig
; RUN: %lld -arch arm64 -lSystem --icf=safe -dylib -o %t/icf-safe.dylib %t/icf-obj.o
; RUN: %lld -arch arm64 -lSystem --icf=all -dylib -o %t/icf-all.dylib %t/icf-obj.o
; RUN: %lld -arch arm64 -lSystem --icf=safe -dylib -o %t/icf-safe.dylib %t/icf-obj.o -no_fixup_chains
; RUN: %lld -arch arm64 -lSystem --icf=all -dylib -o %t/icf-all.dylib %t/icf-obj.o -no_fixup_chains
; RUN: llvm-objdump %t/icf-safe.dylib -d --macho | FileCheck %s --check-prefix=ICFSAFE
; RUN: llvm-objdump %t/icf-all.dylib -d --macho | FileCheck %s --check-prefix=ICFALL

; RUN: llvm-as %s -o %t/icf-bitcode.o
; RUN: %lld -arch arm64 -lSystem --icf=safe -dylib -o %t/icf-safe-bitcode.dylib %t/icf-bitcode.o
; RUN: %lld -arch arm64 -lSystem --icf=all -dylib -o %t/icf-all-bitcode.dylib %t/icf-bitcode.o
; RUN: %lld -arch arm64 -lSystem --icf=safe -dylib -o %t/icf-safe-bitcode.dylib %t/icf-bitcode.o -no_fixup_chains
; RUN: %lld -arch arm64 -lSystem --icf=all -dylib -o %t/icf-all-bitcode.dylib %t/icf-bitcode.o -no_fixup_chains
; RUN: llvm-objdump %t/icf-safe-bitcode.dylib -d --macho | FileCheck %s --check-prefix=ICFSAFE
; RUN: llvm-objdump %t/icf-all-bitcode.dylib -d --macho | FileCheck %s --check-prefix=ICFALL

Expand Down
7 changes: 4 additions & 3 deletions lld/test/MachO/objc-selrefs.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/implicit-selrefs.s -o %t/implicit-selrefs.o

# RUN: %lld -dylib -arch arm64 -lSystem -o %t/explicit-only-no-icf \
# RUN: %t/explicit-selrefs-1.o %t/explicit-selrefs-2.o
# RUN: %t/explicit-selrefs-1.o %t/explicit-selrefs-2.o -no_fixup_chains
# RUN: llvm-otool -vs __DATA __objc_selrefs %t/explicit-only-no-icf | \
# RUN: FileCheck %s --check-prefix=EXPLICIT-NO-ICF

## NOTE: ld64 always dedups the selrefs unconditionally, but we only do it when
## ICF is enabled.
# RUN: %lld -dylib -arch arm64 -lSystem -o %t/explicit-only-with-icf \
# RUN: %t/explicit-selrefs-1.o %t/explicit-selrefs-2.o
# RUN: %t/explicit-selrefs-1.o %t/explicit-selrefs-2.o -no_fixup_chains
# RUN: llvm-otool -vs __DATA __objc_selrefs %t/explicit-only-with-icf \
# RUN: | FileCheck %s --check-prefix=EXPLICIT-WITH-ICF

Expand All @@ -26,7 +26,8 @@

## We don't yet support dedup'ing implicitly-defined selrefs.
# RUN: %lld -dylib -arch arm64 -lSystem --icf=all -o %t/explicit-and-implicit \
# RUN: %t/explicit-selrefs-1.o %t/explicit-selrefs-2.o %t/implicit-selrefs.o
# RUN: %t/explicit-selrefs-1.o %t/explicit-selrefs-2.o %t/implicit-selrefs.o \
# RUN: -no_fixup_chains
# RUN: llvm-otool -vs __DATA __objc_selrefs %t/explicit-and-implicit \
# RUN: | FileCheck %s --check-prefix=EXPLICIT-AND-IMPLICIT

Expand Down

0 comments on commit f35fa7d

Please sign in to comment.