[lld] r357225 - Revert "[WebAssembly] Improve invalid relocation error message"

Derek Schuff via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 28 17:05:01 PDT 2019


Author: dschuff
Date: Thu Mar 28 17:05:00 2019
New Revision: 357225

URL: http://llvm.org/viewvc/llvm-project?rev=357225&view=rev
Log:
Revert "[WebAssembly] Improve invalid relocation error message"

This reverts commit 0805ec5f7b5c80474352531a99e721c30e73e77f.

Modified:
    lld/trunk/test/wasm/undefined-data.ll
    lld/trunk/wasm/InputChunks.cpp
    lld/trunk/wasm/InputChunks.h
    lld/trunk/wasm/Writer.cpp

Modified: lld/trunk/test/wasm/undefined-data.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/undefined-data.ll?rev=357225&r1=357224&r2=357225&view=diff
==============================================================================
--- lld/trunk/test/wasm/undefined-data.ll (original)
+++ lld/trunk/test/wasm/undefined-data.ll Thu Mar 28 17:05:00 2019
@@ -13,4 +13,4 @@ entry:
 }
 
 ; UNDEF: undefined symbol: data_external
-; BADRELOC: undefined-data.ll.tmp.o: relocation R_WASM_MEMORY_ADDR_LEB cannot be used againt symbol data_external; recompile with -fPIC
+; BADRELOC: undefined-data.ll.tmp.o: relocation of type R_WASM_MEMORY_ADDR_* against undefined data symbol: data_external

Modified: lld/trunk/wasm/InputChunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/InputChunks.cpp?rev=357225&r1=357224&r2=357225&view=diff
==============================================================================
--- lld/trunk/wasm/InputChunks.cpp (original)
+++ lld/trunk/wasm/InputChunks.cpp Thu Mar 28 17:05:00 2019
@@ -22,7 +22,7 @@ using namespace llvm::support::endian;
 using namespace lld;
 using namespace lld::wasm;
 
-StringRef lld::reloctTypeToString(uint8_t RelocType) {
+static StringRef reloctTypeToString(uint8_t RelocType) {
   switch (RelocType) {
 #define WASM_RELOC(NAME, REL)                                                  \
   case REL:                                                                    \

Modified: lld/trunk/wasm/InputChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/InputChunks.h?rev=357225&r1=357224&r2=357225&view=diff
==============================================================================
--- lld/trunk/wasm/InputChunks.h (original)
+++ lld/trunk/wasm/InputChunks.h Thu Mar 28 17:05:00 2019
@@ -218,8 +218,6 @@ protected:
 } // namespace wasm
 
 std::string toString(const wasm::InputChunk *);
-StringRef reloctTypeToString(uint8_t RelocType);
-
 } // namespace lld
 
 #endif // LLD_WASM_INPUT_CHUNKS_H

Modified: lld/trunk/wasm/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Writer.cpp?rev=357225&r1=357224&r2=357225&view=diff
==============================================================================
--- lld/trunk/wasm/Writer.cpp (original)
+++ lld/trunk/wasm/Writer.cpp Thu Mar 28 17:05:00 2019
@@ -1141,6 +1141,18 @@ void Writer::processRelocations(InputChu
       File->TypeMap[Reloc.Index] = registerType(Types[Reloc.Index]);
       File->TypeIsUsed[Reloc.Index] = true;
       break;
+    case R_WASM_MEMORY_ADDR_SLEB:
+    case R_WASM_MEMORY_ADDR_I32:
+    case R_WASM_MEMORY_ADDR_LEB: {
+      DataSymbol *DataSym = File->getDataSymbol(Reloc.Index);
+      if (!Config->Relocatable && !isa<DefinedData>(DataSym) &&
+          !DataSym->isWeak())
+        error(File->getName() +
+              ": relocation of type R_WASM_MEMORY_ADDR_* "
+              "against undefined data symbol: " +
+              DataSym->getName());
+      break;
+    }
     case R_WASM_GLOBAL_INDEX_LEB: {
       auto* Sym = File->getSymbols()[Reloc.Index];
       if (!isa<GlobalSymbol>(Sym) && !Sym->isInGOT()) {
@@ -1149,23 +1161,6 @@ void Writer::processRelocations(InputChu
       }
     }
     }
-
-    if (!Config->Relocatable) {
-      switch (Reloc.Type) {
-      // These relocations types appear the code section.
-      // They should never appear in code compiled with -fPIC.
-      case R_WASM_TABLE_INDEX_SLEB:
-      case R_WASM_MEMORY_ADDR_I32:
-      case R_WASM_MEMORY_ADDR_LEB: {
-        auto *Sym = File->getSymbols()[Reloc.Index];
-        if (Sym->isUndefined() && !Sym->isWeak())
-          error(File->getName() + ": relocation " +
-                reloctTypeToString(Reloc.Type) +
-                " cannot be used againt symbol " + Sym->getName() +
-                "; recompile with -fPIC");
-      }
-      }
-    }
   }
 }
 




More information about the llvm-commits mailing list