1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[lld][WebAssembly] Add support for handling table symbols

This commit adds table symbol support in a partial way, while still
including some special cases for the __indirect_function_table symbol.
No change in tests.

Differential Revision: https://reviews.llvm.org/D94075
This commit is contained in:
Andy Wingo 2021-01-05 12:08:58 +01:00
parent a94ec580f1
commit a312ae5a63
4 changed files with 9 additions and 9 deletions

View File

@ -192,8 +192,8 @@ struct WasmSymbolInfo {
// For symbols to be exported from the final module
Optional<StringRef> ExportName;
union {
// For function or global symbols, the index in function or global index
// space.
// For function, table, or global symbols, the index in function, table, or
// global index space.
uint32_t ElementIndex;
// For a data symbols, the address of the data relative to segment.
WasmDataReference DataRef;

View File

@ -35,7 +35,8 @@ namespace object {
class WasmSymbol {
public:
WasmSymbol(const wasm::WasmSymbolInfo &Info,
const wasm::WasmGlobalType *GlobalType, const uint8_t TableType,
const wasm::WasmGlobalType *GlobalType,
const wasm::WasmTableType *TableType,
const wasm::WasmEventType *EventType,
const wasm::WasmSignature *Signature)
: Info(Info), GlobalType(GlobalType), TableType(TableType),
@ -43,7 +44,7 @@ public:
const wasm::WasmSymbolInfo &Info;
const wasm::WasmGlobalType *GlobalType;
const uint8_t TableType;
const wasm::WasmTableType *TableType;
const wasm::WasmEventType *EventType;
const wasm::WasmSignature *Signature;

View File

@ -527,7 +527,7 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
wasm::WasmSymbolInfo Info;
const wasm::WasmSignature *Signature = nullptr;
const wasm::WasmGlobalType *GlobalType = nullptr;
uint8_t TableType = 0;
const wasm::WasmTableType *TableType = nullptr;
const wasm::WasmEventType *EventType = nullptr;
Info.Kind = readUint8(Ctx);
@ -609,7 +609,7 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
Info.Name = readString(Ctx);
unsigned TableIndex = Info.ElementIndex - NumImportedTables;
wasm::WasmTable &Table = Tables[TableIndex];
TableType = Table.Type.ElemType;
TableType = &Table.Type;
if (Table.SymbolName.empty())
Table.SymbolName = Info.Name;
} else {
@ -620,8 +620,7 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
} else {
Info.Name = Import.Field;
}
TableType = Import.Table.ElemType;
// FIXME: Parse limits here too.
TableType = &Import.Table;
if (!Import.Module.empty()) {
Info.ImportModule = Import.Module;
}

View File

@ -24,7 +24,7 @@ static const EnumEntry<unsigned> WasmSymbolTypes[] = {
#define ENUM_ENTRY(X) \
{ #X, wasm::WASM_SYMBOL_TYPE_##X }
ENUM_ENTRY(FUNCTION), ENUM_ENTRY(DATA), ENUM_ENTRY(GLOBAL),
ENUM_ENTRY(SECTION), ENUM_ENTRY(EVENT),
ENUM_ENTRY(SECTION), ENUM_ENTRY(EVENT), ENUM_ENTRY(TABLE),
#undef ENUM_ENTRY
};