Skip to content

Commit e99ad26

Browse files
authored
Merge pull request #3605 from swiftwasm/maxd/image-inspection-wasm
runtime: move Wasm code to ImageInspectionWasm.cpp
2 parents 46b37c3 + 56a7b60 commit e99ad26

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

stdlib/public/runtime/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
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
@@ -123,7 +124,7 @@ foreach(sdk IN LISTS SWIFT_SDKS)
123124
set(image_inspection_shared_file ImageInspectionELF.cpp)
124125
elseif(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "WASI")
125126
set(image_inspection_shared_sdk "${sdk}")
126-
set(image_inspection_shared_file ImageInspectionELF.cpp)
127+
set(image_inspection_shared_file ImageInspectionWasm.cpp)
127128
# Set default arch
128129
set(primary_arch "wasm32")
129130
endif()

stdlib/public/runtime/ImageInspectionCOFF.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if !defined(__ELF__) && !defined(__MACH__) && !defined(__wasm__)
13+
#if !defined(__ELF__) && !defined(__MACH__)
1414

1515
#include "ImageInspection.h"
1616

stdlib/public/runtime/ImageInspectionELF.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,15 @@
1818
///
1919
//===----------------------------------------------------------------------===//
2020

21-
#if defined(__ELF__) || defined(__wasm__)
21+
#if defined(__ELF__)
2222

2323
#include "../SwiftShims/MetadataSections.h"
2424
#include "ImageInspection.h"
25-
#ifndef __wasm__
2625
#include <dlfcn.h>
27-
#endif
2826

2927
using namespace swift;
3028

3129
int swift::lookupSymbol(const void *address, SymbolInfo *info) {
32-
#ifndef __wasm__
3330
Dl_info dlinfo;
3431
if (dladdr(address, &dlinfo) == 0) {
3532
return 0;
@@ -40,9 +37,6 @@ int swift::lookupSymbol(const void *address, SymbolInfo *info) {
4037
info->symbolName.reset(dlinfo.dli_sname);
4138
info->symbolAddress = dlinfo.dli_saddr;
4239
return 1;
43-
#else
44-
return 0;
45-
#endif
4640
}
4741

4842
#endif // defined(__ELF__)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//===--- ImageInspectionStatic.cpp - image inspection for static stdlib ---===//
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+
return 0;
28+
}
29+
30+
#endif // defined(__wasm__)

0 commit comments

Comments
 (0)