[lld] r247796 - [Mips] Rejects all --hash-style arguments except 'sysv' in case of MIPS target

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 16 06:36:32 PDT 2015


Author: atanasyan
Date: Wed Sep 16 08:36:32 2015
New Revision: 247796

URL: http://llvm.org/viewvc/llvm-project?rev=247796&view=rev
Log:
[Mips] Rejects all --hash-style arguments except 'sysv' in case of MIPS target

MIPS ABI supports only --hash-style=sysv variant.

Added:
    lld/trunk/test/elf/Mips/driver-hash-style.test
Modified:
    lld/trunk/lib/Driver/GnuLdDriver.cpp

Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=247796&r1=247795&r2=247796&view=diff
==============================================================================
--- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/GnuLdDriver.cpp Wed Sep 16 08:36:32 2015
@@ -540,8 +540,14 @@ bool GnuLdDriver::parse(llvm::ArrayRef<c
   if (triple.getArch() == llvm::Triple::mips ||
       triple.getArch() == llvm::Triple::mipsel ||
       triple.getArch() == llvm::Triple::mips64 ||
-      triple.getArch() == llvm::Triple::mips64el)
+      triple.getArch() == llvm::Triple::mips64el) {
     ctx->setMipsPcRelEhRel(parsedArgs.hasArg(OPT_pcrel_eh_reloc));
+    auto *hashArg = parsedArgs.getLastArg(OPT_hash_style);
+    if (hashArg && hashArg->getValue() != StringRef("sysv")) {
+      diag << "error: .gnu.hash is incompatible with the MIPS ABI\n";
+      return false;
+    }
+  }
   else {
     for (const auto *arg : parsedArgs.filtered(OPT_grp_mips_targetopts)) {
       diag << "warning: ignoring unsupported MIPS specific argument: "

Added: lld/trunk/test/elf/Mips/driver-hash-style.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/driver-hash-style.test?rev=247796&view=auto
==============================================================================
--- lld/trunk/test/elf/Mips/driver-hash-style.test (added)
+++ lld/trunk/test/elf/Mips/driver-hash-style.test Wed Sep 16 08:36:32 2015
@@ -0,0 +1,15 @@
+# REQUIRES: mips
+
+# Check that the driver rejects all --hash-style arguments except 'sysv'
+# because it is the only style supported by MIPS ABI.
+
+# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
+# RUN: not lld -flavor gnu -target mips --hash-style=both %t.o -o %t.exe 2>&1 \
+# RUN:       | FileCheck %s
+# RUN: not lld -flavor gnu -target mips --hash-style=gnu %t.o -o %t.exe 2>&1 \
+# RUN:       | FileCheck %s
+
+# CHECK: error: .gnu.hash is incompatible with the MIPS ABI
+
+  .globl __start;
+__start:




More information about the llvm-commits mailing list