diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -843,6 +843,20 @@ } static bool dataConstDefault(const InputArgList &args) { + static const std::map minVersion = { + {PlatformKind::macOS, VersionTuple(10, 15)}, + {PlatformKind::iOS, VersionTuple(13, 0)}, + {PlatformKind::iOSSimulator, VersionTuple(13, 0)}, + {PlatformKind::tvOS, VersionTuple(13, 0)}, + {PlatformKind::tvOSSimulator, VersionTuple(13, 0)}, + {PlatformKind::watchOS, VersionTuple(6, 0)}, + {PlatformKind::watchOSSimulator, VersionTuple(6, 0)}, + {PlatformKind::bridgeOS, VersionTuple(4, 0)}}; + auto it = minVersion.find(config->platformInfo.target.Platform); + if (it != minVersion.end()) + if (config->platformInfo.minimum < it->second) + return false; + switch (config->outputType) { case MH_EXECUTE: return !args.hasArg(OPT_no_pie); diff --git a/lld/test/MachO/builtin-rename.s b/lld/test/MachO/builtin-rename.s --- a/lld/test/MachO/builtin-rename.s +++ b/lld/test/MachO/builtin-rename.s @@ -10,6 +10,7 @@ # RUN: %lld -o %t/ydata %t/main.o %t/renames.o -lSystem # RUN: %lld -no_data_const -o %t/ndata %t/main.o %t/renames.o -lSystem # RUN: %lld -no_pie -o %t/nopie %t/main.o %t/renames.o -lSystem +# RUN: %lld -platform_version macos 10.14 11.0 -o %t/old %t/main.o %t/renames.o -lSystem # RUN: llvm-objdump --syms %t/ydata | \ # RUN: FileCheck %s --check-prefixes=CHECK,YDATA @@ -17,6 +18,8 @@ # RUN: FileCheck %s --check-prefixes=CHECK,NDATA # RUN: llvm-objdump --syms %t/nopie | \ # RUN: FileCheck %s --check-prefixes=CHECK,NDATA +# RUN: llvm-objdump --syms %t/old | \ +# RUN: FileCheck %s --check-prefixes=CHECK,NDATA # CHECK-LABEL: {{^}}SYMBOL TABLE: