[PATCH] D105080: [lld-macho] Only enable `__DATA_CONST` for newer platforms

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 28 20:59:26 PDT 2021


int3 created this revision.
int3 added a reviewer: lld-macho.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
int3 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Matches ld64.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105080

Files:
  lld/MachO/Driver.cpp
  lld/test/MachO/builtin-rename.s


Index: lld/test/MachO/builtin-rename.s
===================================================================
--- lld/test/MachO/builtin-rename.s
+++ 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:
 
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -843,6 +843,20 @@
 }
 
 static bool dataConstDefault(const InputArgList &args) {
+  static const std::map<PlatformKind, VersionTuple> 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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105080.355108.patch
Type: text/x-patch
Size: 1897 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210629/d36de790/attachment.bin>


More information about the llvm-commits mailing list