From a221ab18f5878a9db22650b8d6c53f03172e8782 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 28 Sep 2021 14:43:55 +0100 Subject: [PATCH 1/2] runtime, WebAssembly: add ImageInspectionWasm.cpp This change adds a stub for `swift::lookupSymbol` for the WebAssembly platform. Related to SR-9307. --- stdlib/public/runtime/ImageInspectionWasm.cpp | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 stdlib/public/runtime/ImageInspectionWasm.cpp diff --git a/stdlib/public/runtime/ImageInspectionWasm.cpp b/stdlib/public/runtime/ImageInspectionWasm.cpp new file mode 100644 index 0000000000000..eaca2aeca7085 --- /dev/null +++ b/stdlib/public/runtime/ImageInspectionWasm.cpp @@ -0,0 +1,30 @@ +//===--- ImageInspectionStatic.cpp - image inspection for static stdlib ---===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// +/// Implementation of ImageInspection for WebAssembly. +/// +//===----------------------------------------------------------------------===// + +#if defined(__wasm__) + +#include "../SwiftShims/MetadataSections.h" +#include "ImageInspection.h" + +using namespace swift; + +int swift::lookupSymbol(const void *address, SymbolInfo *info) { + return 0; +} + +#endif // defined(__wasm__) From 1ce667859cdc005d745ad82133dea91bac1c705a Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 28 Sep 2021 14:45:14 +0100 Subject: [PATCH 2/2] runtime, CMake: add `ImageInspectionWasm.cpp` --- stdlib/public/runtime/CMakeLists.txt | 1 + stdlib/public/runtime/ImageInspectionWasm.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/stdlib/public/runtime/CMakeLists.txt b/stdlib/public/runtime/CMakeLists.txt index fdb5472a6d144..ef38c5756e7c6 100644 --- a/stdlib/public/runtime/CMakeLists.txt +++ b/stdlib/public/runtime/CMakeLists.txt @@ -53,6 +53,7 @@ set(swift_runtime_sources ImageInspectionELF.cpp ImageInspectionCOFF.cpp ImageInspectionStatic.cpp + ImageInspectionWasm.cpp KeyPaths.cpp KnownMetadata.cpp Metadata.cpp diff --git a/stdlib/public/runtime/ImageInspectionWasm.cpp b/stdlib/public/runtime/ImageInspectionWasm.cpp index eaca2aeca7085..165aa0990b1cf 100644 --- a/stdlib/public/runtime/ImageInspectionWasm.cpp +++ b/stdlib/public/runtime/ImageInspectionWasm.cpp @@ -1,4 +1,4 @@ -//===--- ImageInspectionStatic.cpp - image inspection for static stdlib ---===// +//===----------------------------------------------------------------------===// // // This source file is part of the Swift.org open source project // @@ -24,6 +24,11 @@ using namespace swift; int swift::lookupSymbol(const void *address, SymbolInfo *info) { + // Currently, Wasm doesn't have a standard stable ABI for exporting address <-> + // symbol table, it's work in progress. Also, there is no API to access such + // information from Wasm binary side. It's accessible only from host VM. + // See https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md + // Seems reasonable to use a stub for now. return 0; }