summaryrefslogtreecommitdiffstats
path: root/lld/wasm/Writer.cpp
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2019-03-28 02:02:07 +0000
committerSam Clegg <sbc@chromium.org>2019-03-28 02:02:07 +0000
commit0805ec5f7b5c80474352531a99e721c30e73e77f (patch)
tree4687e8c852bd07c008e6b9317befa58a7d6916c2 /lld/wasm/Writer.cpp
parent0a2d0c1f5ff018576681c5514846ad1963f7b1a2 (diff)
downloadbcm5719-llvm-0805ec5f7b5c80474352531a99e721c30e73e77f.tar.gz
bcm5719-llvm-0805ec5f7b5c80474352531a99e721c30e73e77f.zip
[WebAssembly] Improve invalid relocation error message
This message now matches the equivalent message in the ELF linker. Differential Revision: https://reviews.llvm.org/D59860 llvm-svn: 357143
Diffstat (limited to 'lld/wasm/Writer.cpp')
-rw-r--r--lld/wasm/Writer.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index 480257f18bd..4697540e5e5 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -1141,18 +1141,6 @@ 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()) {
@@ -1161,6 +1149,23 @@ 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