Skip to content

runtime: move Wasm code to ImageInspectionWasm.cpp #3605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion stdlib/public/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ set(swift_runtime_sources
ImageInspectionELF.cpp
ImageInspectionCOFF.cpp
ImageInspectionStatic.cpp
ImageInspectionWasm.cpp
KeyPaths.cpp
KnownMetadata.cpp
Metadata.cpp
Expand Down Expand Up @@ -123,7 +124,7 @@ foreach(sdk IN LISTS SWIFT_SDKS)
set(image_inspection_shared_file ImageInspectionELF.cpp)
elseif(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "WASI")
set(image_inspection_shared_sdk "${sdk}")
set(image_inspection_shared_file ImageInspectionELF.cpp)
set(image_inspection_shared_file ImageInspectionWasm.cpp)
# Set default arch
set(primary_arch "wasm32")
endif()
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/runtime/ImageInspectionCOFF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//

#if !defined(__ELF__) && !defined(__MACH__) && !defined(__wasm__)
#if !defined(__ELF__) && !defined(__MACH__)

#include "ImageInspection.h"

Expand Down
8 changes: 1 addition & 7 deletions stdlib/public/runtime/ImageInspectionELF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,15 @@
///
//===----------------------------------------------------------------------===//

#if defined(__ELF__) || defined(__wasm__)
#if defined(__ELF__)

#include "../SwiftShims/MetadataSections.h"
#include "ImageInspection.h"
#ifndef __wasm__
#include <dlfcn.h>
#endif

using namespace swift;

int swift::lookupSymbol(const void *address, SymbolInfo *info) {
#ifndef __wasm__
Dl_info dlinfo;
if (dladdr(address, &dlinfo) == 0) {
return 0;
Expand All @@ -40,9 +37,6 @@ int swift::lookupSymbol(const void *address, SymbolInfo *info) {
info->symbolName.reset(dlinfo.dli_sname);
info->symbolAddress = dlinfo.dli_saddr;
return 1;
#else
return 0;
#endif
}

#endif // defined(__ELF__)
30 changes: 30 additions & 0 deletions stdlib/public/runtime/ImageInspectionWasm.cpp
Original file line number Diff line number Diff line change
@@ -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__)