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: \
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()) {
}
}
}
-
- 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");
- }
- }
- }
}
}