summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Schuff <dschuff@google.com>2019-03-29 00:05:00 +0000
committerDerek Schuff <dschuff@google.com>2019-03-29 00:05:00 +0000
commit0c9ea1053058be474a58859be2ab212aaf33ea31 (patch)
tree258246e73c4371daa5bcc057128e281d51b24901
parentac727e86473be03bbc1c4a436305d2771e3a9acd (diff)
downloadbcm5719-llvm-0c9ea1053058be474a58859be2ab212aaf33ea31.tar.gz
bcm5719-llvm-0c9ea1053058be474a58859be2ab212aaf33ea31.zip
Revert "[WebAssembly] Improve invalid relocation error message"
This reverts commit 0805ec5f7b5c80474352531a99e721c30e73e77f. llvm-svn: 357225
-rw-r--r--lld/test/wasm/undefined-data.ll2
-rw-r--r--lld/wasm/InputChunks.cpp2
-rw-r--r--lld/wasm/InputChunks.h2
-rw-r--r--lld/wasm/Writer.cpp29
4 files changed, 14 insertions, 21 deletions
diff --git a/lld/test/wasm/undefined-data.ll b/lld/test/wasm/undefined-data.ll
index 21691bc3cfc..8063d333efa 100644
--- a/lld/test/wasm/undefined-data.ll
+++ b/lld/test/wasm/undefined-data.ll
@@ -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
diff --git a/lld/wasm/InputChunks.cpp b/lld/wasm/InputChunks.cpp
index 15e57a8e4c2..5d6dfa0d989 100644
--- a/lld/wasm/InputChunks.cpp
+++ b/lld/wasm/InputChunks.cpp
@@ -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: \
diff --git a/lld/wasm/InputChunks.h b/lld/wasm/InputChunks.h
index 8f0999abac6..20b8f01f61a 100644
--- a/lld/wasm/InputChunks.h
+++ b/lld/wasm/InputChunks.h
@@ -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
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index 4697540e5e5..480257f18bd 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -1141,6 +1141,18 @@ void Writer::processRelocations(InputChunk *Chunk) {
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(InputChunk *Chunk) {
}
}
}
-
- 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");
- }
- }
- }
}
}
OpenPOWER on IntegriCloud