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 Index: tools/driver/cc1as_main.cpp =================================================================== --- tools/driver/cc1as_main.cpp +++ tools/driver/cc1as_main.cpp @@ -344,12 +344,20 @@ std::unique_ptr 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!");