mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-03-09 05:02:19 +00:00
[lld-macho] Allow deduplicate-literals to be overridden
It's still uncertain but whether we want to have `deduplicate-literals` be the default flag for LLD out of the box or not. If `deduplicate-literals` is the default behavior, then we will need a way override it and not deduplicate. Luckily, we have `no_deduplicate` to fill this gap. For now, I've set the default to be false which aligns with the existing behavior. That can only always be changed after discussions on D117250. Reviewed By: #lld-macho, int3 Differential Revision: https://reviews.llvm.org/D117387
This commit is contained in:
parent
a567961574
commit
e5347f2556
@ -1281,8 +1281,9 @@ bool macho::link(ArrayRef<const char *> argsArr, bool canExitEarly,
|
||||
config->emitDataInCodeInfo =
|
||||
args.hasFlag(OPT_data_in_code_info, OPT_no_data_in_code_info, true);
|
||||
config->icfLevel = getICFLevel(args);
|
||||
config->dedupLiterals = args.hasArg(OPT_deduplicate_literals) ||
|
||||
config->icfLevel != ICFLevel::none;
|
||||
config->dedupLiterals =
|
||||
args.hasFlag(OPT_deduplicate_literals, OPT_icf_eq, false) ||
|
||||
config->icfLevel != ICFLevel::none;
|
||||
config->warnDylibInstallName = args.hasFlag(
|
||||
OPT_warn_dylib_install_name, OPT_no_warn_dylib_install_name, false);
|
||||
config->callGraphProfileSort = args.hasFlag(
|
||||
|
@ -4,6 +4,13 @@ LD64 vs LLD-MACHO
|
||||
|
||||
This doc lists all significant deliberate differences in behavior between LD64 and LLD-MachO.
|
||||
|
||||
``-no_deduplicate`` Flag
|
||||
**********************
|
||||
- LD64:
|
||||
* This turns off ICF (deduplication pass) in the linker.
|
||||
- LLD
|
||||
* This turns off ICF and string merging in the linker.
|
||||
|
||||
ObjC symbols treatment
|
||||
**********************
|
||||
There are differences in how LLD and LD64 handle ObjC symbols loaded from archives.
|
||||
|
@ -6,6 +6,29 @@
|
||||
# RUN: llvm-objdump --macho --section="__TEXT,__literals" --section="__DATA,ptrs" --syms %t/test | FileCheck %s
|
||||
# RUN: llvm-readobj --section-headers %t/test | FileCheck %s --check-prefix=HEADER
|
||||
|
||||
## Make sure literal deduplication can be overridden or that the later flag wins.
|
||||
# RUN: %lld -dylib --deduplicate-literals -no_deduplicate %t/test.o %t/qux.o -o %t/no-dedup-test
|
||||
# RUN: llvm-objdump --macho --section="__TEXT,__literals" --section="__DATA,ptrs" %t/no-dedup-test | FileCheck %s --check-prefix=NO-DEDUP
|
||||
|
||||
# RUN: %lld -dylib -no_deduplicate --deduplicate-literals %t/test.o %t/qux.o -o %t/test
|
||||
# RUN: llvm-objdump --macho --section="__TEXT,__literals" --section="__DATA,ptrs" --syms %t/test | FileCheck %s
|
||||
# RUN: llvm-readobj --section-headers %t/test | FileCheck %s --check-prefix=HEADER
|
||||
|
||||
# NO-DEDUP-NOT: Contents of (__TEXT,__literals) section
|
||||
# NO-DEDUP: Contents of (__DATA,ptrs) section
|
||||
# NO-DEDUP-NEXT: __TEXT:__literal16:0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
|
||||
# NO-DEDUP-NEXT: __TEXT:__literal16:0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
|
||||
# NO-DEDUP-NEXT: __TEXT:__literal16:0xfeedface 0xfeedface 0xfeedface 0xfeedface
|
||||
# NO-DEDUP-NEXT: __TEXT:__literal16:0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
|
||||
# NO-DEDUP-NEXT: __TEXT:__literal8:0xdeadbeef 0xdeadbeef
|
||||
# NO-DEDUP-NEXT: __TEXT:__literal8:0xdeadbeef 0xdeadbeef
|
||||
# NO-DEDUP-NEXT: __TEXT:__literal8:0xfeedface 0xfeedface
|
||||
# NO-DEDUP-NEXT: __TEXT:__literal8:0xdeadbeef 0xdeadbeef
|
||||
# NO-DEDUP-NEXT: __TEXT:__literal4:0xdeadbeef
|
||||
# NO-DEDUP-NEXT: __TEXT:__literal4:0xdeadbeef
|
||||
# NO-DEDUP-NEXT: __TEXT:__literal4:0xfeedface
|
||||
# NO-DEDUP-NEXT: __TEXT:__literal4:0xdeadbeef
|
||||
|
||||
# CHECK: Contents of (__TEXT,__literals) section
|
||||
# CHECK-NEXT: [[#%.16x,DEADBEEF16:]] ef be ad de ef be ad de ef be ad de ef be ad de
|
||||
# CHECK-NEXT: [[#%.16x,FEEDFACE16:]] ce fa ed fe ce fa ed fe ce fa ed fe ce fa ed fe
|
||||
|
@ -6,7 +6,6 @@
|
||||
## `--version` flag.)
|
||||
# RUN: %lld --version \
|
||||
# RUN: -dynamic \
|
||||
# RUN: -no_deduplicate \
|
||||
# RUN: -lto_library /lib/foo \
|
||||
# RUN: -macosx_version_min 0 \
|
||||
# RUN: -no_dtrace_dof \
|
||||
|
Loading…
x
Reference in New Issue
Block a user