Skip to content

Commit b41b414

Browse files
committed
[lld-macho] Only enable __DATA_CONST for newer platforms
Matches ld64. Reviewed By: #lld-macho, alexander-shaposhnikov Differential Revision: https://reviews.llvm.org/D105080
1 parent 0d6d35e commit b41b414

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lld/MachO/Driver.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,20 @@ static std::vector<SectionAlign> parseSectAlign(const opt::InputArgList &args) {
841841
}
842842

843843
static bool dataConstDefault(const InputArgList &args) {
844+
static const std::map<PlatformKind, VersionTuple> minVersion = {
845+
{PlatformKind::macOS, VersionTuple(10, 15)},
846+
{PlatformKind::iOS, VersionTuple(13, 0)},
847+
{PlatformKind::iOSSimulator, VersionTuple(13, 0)},
848+
{PlatformKind::tvOS, VersionTuple(13, 0)},
849+
{PlatformKind::tvOSSimulator, VersionTuple(13, 0)},
850+
{PlatformKind::watchOS, VersionTuple(6, 0)},
851+
{PlatformKind::watchOSSimulator, VersionTuple(6, 0)},
852+
{PlatformKind::bridgeOS, VersionTuple(4, 0)}};
853+
auto it = minVersion.find(config->platformInfo.target.Platform);
854+
if (it != minVersion.end())
855+
if (config->platformInfo.minimum < it->second)
856+
return false;
857+
844858
switch (config->outputType) {
845859
case MH_EXECUTE:
846860
return !args.hasArg(OPT_no_pie);

lld/test/MachO/builtin-rename.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@
1010
# RUN: %lld -o %t/ydata %t/main.o %t/renames.o -lSystem
1111
# RUN: %lld -no_data_const -o %t/ndata %t/main.o %t/renames.o -lSystem
1212
# RUN: %lld -no_pie -o %t/nopie %t/main.o %t/renames.o -lSystem
13+
# RUN: %lld -platform_version macos 10.14 11.0 -o %t/old %t/main.o %t/renames.o -lSystem
1314

1415
# RUN: llvm-objdump --syms %t/ydata | \
1516
# RUN: FileCheck %s --check-prefixes=CHECK,YDATA
1617
# RUN: llvm-objdump --syms %t/ndata | \
1718
# RUN: FileCheck %s --check-prefixes=CHECK,NDATA
1819
# RUN: llvm-objdump --syms %t/nopie | \
1920
# RUN: FileCheck %s --check-prefixes=CHECK,NDATA
21+
# RUN: llvm-objdump --syms %t/old | \
22+
# RUN: FileCheck %s --check-prefixes=CHECK,NDATA
2023

2124
# CHECK-LABEL: {{^}}SYMBOL TABLE:
2225

0 commit comments

Comments
 (0)