Skip to content

Commit 0c9ea10

Browse files
committed
Revert "[WebAssembly] Improve invalid relocation error message"
This reverts commit 0805ec5. llvm-svn: 357225
1 parent ac727e8 commit 0c9ea10

File tree

4 files changed

+14
-21
lines changed

4 files changed

+14
-21
lines changed

lld/test/wasm/undefined-data.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ entry:
1313
}
1414

1515
; UNDEF: undefined symbol: data_external
16-
; BADRELOC: undefined-data.ll.tmp.o: relocation R_WASM_MEMORY_ADDR_LEB cannot be used againt symbol data_external; recompile with -fPIC
16+
; BADRELOC: undefined-data.ll.tmp.o: relocation of type R_WASM_MEMORY_ADDR_* against undefined data symbol: data_external

lld/wasm/InputChunks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ using namespace llvm::support::endian;
2222
using namespace lld;
2323
using namespace lld::wasm;
2424

25-
StringRef lld::reloctTypeToString(uint8_t RelocType) {
25+
static StringRef reloctTypeToString(uint8_t RelocType) {
2626
switch (RelocType) {
2727
#define WASM_RELOC(NAME, REL) \
2828
case REL: \

lld/wasm/InputChunks.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,6 @@ class InputSection : public InputChunk {
218218
} // namespace wasm
219219

220220
std::string toString(const wasm::InputChunk *);
221-
StringRef reloctTypeToString(uint8_t RelocType);
222-
223221
} // namespace lld
224222

225223
#endif // LLD_WASM_INPUT_CHUNKS_H

lld/wasm/Writer.cpp

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,18 @@ void Writer::processRelocations(InputChunk *Chunk) {
11411141
File->TypeMap[Reloc.Index] = registerType(Types[Reloc.Index]);
11421142
File->TypeIsUsed[Reloc.Index] = true;
11431143
break;
1144+
case R_WASM_MEMORY_ADDR_SLEB:
1145+
case R_WASM_MEMORY_ADDR_I32:
1146+
case R_WASM_MEMORY_ADDR_LEB: {
1147+
DataSymbol *DataSym = File->getDataSymbol(Reloc.Index);
1148+
if (!Config->Relocatable && !isa<DefinedData>(DataSym) &&
1149+
!DataSym->isWeak())
1150+
error(File->getName() +
1151+
": relocation of type R_WASM_MEMORY_ADDR_* "
1152+
"against undefined data symbol: " +
1153+
DataSym->getName());
1154+
break;
1155+
}
11441156
case R_WASM_GLOBAL_INDEX_LEB: {
11451157
auto* Sym = File->getSymbols()[Reloc.Index];
11461158
if (!isa<GlobalSymbol>(Sym) && !Sym->isInGOT()) {
@@ -1149,23 +1161,6 @@ void Writer::processRelocations(InputChunk *Chunk) {
11491161
}
11501162
}
11511163
}
1152-
1153-
if (!Config->Relocatable) {
1154-
switch (Reloc.Type) {
1155-
// These relocations types appear the code section.
1156-
// They should never appear in code compiled with -fPIC.
1157-
case R_WASM_TABLE_INDEX_SLEB:
1158-
case R_WASM_MEMORY_ADDR_I32:
1159-
case R_WASM_MEMORY_ADDR_LEB: {
1160-
auto *Sym = File->getSymbols()[Reloc.Index];
1161-
if (Sym->isUndefined() && !Sym->isWeak())
1162-
error(File->getName() + ": relocation " +
1163-
reloctTypeToString(Reloc.Type) +
1164-
" cannot be used againt symbol " + Sym->getName() +
1165-
"; recompile with -fPIC");
1166-
}
1167-
}
1168-
}
11691164
}
11701165
}
11711166

0 commit comments

Comments
 (0)