[PATCH] D35970: Teach cc1as driver to accept ARM ropi/rwpi reloc model

Weiming Zhao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 31 15:05:48 PDT 2017


weimingz updated this revision to Diff 109009.
weimingz added a comment.

add test case


https://reviews.llvm.org/D35970

Files:
  test/Driver/ropi-rwpi.S
  tools/driver/cc1as_main.cpp


Index: tools/driver/cc1as_main.cpp
===================================================================
--- tools/driver/cc1as_main.cpp
+++ tools/driver/cc1as_main.cpp
@@ -344,12 +344,20 @@
   std::unique_ptr<MCObjectFileInfo> MOFI(new MCObjectFileInfo());
 
   MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), &SrcMgr);
+  Triple T(Opts.Triple);
+  auto Arch = T.getArch();
 
   bool PIC = false;
   if (Opts.RelocationModel == "static") {
     PIC = false;
   } else if (Opts.RelocationModel == "pic") {
     PIC = true;
+  } else if ((Arch == llvm::Triple::arm || Arch == llvm::Triple::armeb ||
+              Arch == llvm::Triple::thumb || Arch == llvm::Triple::thumbeb) &&
+             (Opts.RelocationModel == "ropi" ||
+              Opts.RelocationModel == "rwpi" ||
+              Opts.RelocationModel == "ropi-rwpi")) {
+    PIC = false;
   } else {
     assert(Opts.RelocationModel == "dynamic-no-pic" &&
            "Invalid PIC model!");
Index: test/Driver/ropi-rwpi.S
===================================================================
--- /dev/null
+++ test/Driver/ropi-rwpi.S
@@ -0,0 +1,7 @@
+// RUN: %clang -target arm-none-eabi -frwpi -c %s -o %t
+// RUN: %clang -target arm-none-eabi -fropi -c %s -o %t
+// RUN: %clang -target arm-none-eabi -fropi -frwpi -c %s -o %t
+// RUN: %clang -target armeb-none-eabi -fropi -c %s -o %t
+// RUN: %clang -target thumb-none-eabi -fropi -c %s -o %t
+// RUN: %clang -target thumbeb-none-eabi -fropi -c %s -o %t
+// RUN-NOT: %clang -target x86_64-linux-gnu -fropi  -c %s -o %t


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35970.109009.patch
Type: text/x-patch
Size: 1529 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170731/73bc5259/attachment.bin>


More information about the llvm-commits mailing list