Skip to content

Commit a94e961

Browse files
authored
runtime, WebAssembly: add ImageInspectionWasm.cpp (#39483)
This change adds a stub for `swift::lookupSymbol` for the WebAssembly platform. Related to SR-9307.
1 parent 5011300 commit a94e961

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

stdlib/public/runtime/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ set(swift_runtime_sources
5353
ImageInspectionELF.cpp
5454
ImageInspectionCOFF.cpp
5555
ImageInspectionStatic.cpp
56+
ImageInspectionWasm.cpp
5657
KeyPaths.cpp
5758
KnownMetadata.cpp
5859
Metadata.cpp
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
///
13+
/// \file
14+
///
15+
/// Implementation of ImageInspection for WebAssembly.
16+
///
17+
//===----------------------------------------------------------------------===//
18+
19+
#if defined(__wasm__)
20+
21+
#include "../SwiftShims/MetadataSections.h"
22+
#include "ImageInspection.h"
23+
24+
using namespace swift;
25+
26+
int swift::lookupSymbol(const void *address, SymbolInfo *info) {
27+
// Currently, Wasm doesn't have a standard stable ABI for exporting address <->
28+
// symbol table, it's work in progress. Also, there is no API to access such
29+
// information from Wasm binary side. It's accessible only from host VM.
30+
// See https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md
31+
// Seems reasonable to use a stub for now.
32+
return 0;
33+
}
34+
35+
#endif // defined(__wasm__)

0 commit comments

Comments
 (0)