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

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 30 15:56:17 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGb41b4148e7b9: [lld-macho] Only enable `__DATA_CONST` for newer platforms (authored by int3).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105080/new/

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
@@ -841,6 +841,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.355710.patch
Type: text/x-patch
Size: 1897 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210630/a5b57bf7/attachment.bin>


More information about the llvm-commits mailing list