summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/wasm-binary.h1
-rw-r--r--src/wasm/wasm-binary.cpp27
-rw-r--r--src/wasm/wasm.cpp1
3 files changed, 28 insertions, 1 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index d568abd6c..989ce891a 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -414,6 +414,7 @@ extern const char* Dylink;
extern const char* Dylink0;
extern const char* Linking;
extern const char* Producers;
+extern const char* BuildId;
extern const char* TargetFeatures;
extern const char* AtomicsFeature;
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index d9985212f..4082fbf5f 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -16,6 +16,7 @@
#include <algorithm>
#include <fstream>
+#include <iomanip>
#include "ir/eh-utils.h"
#include "ir/module-utils.h"
@@ -1212,7 +1213,31 @@ void WasmBinaryWriter::initializeDebugInfo() {
}
void WasmBinaryWriter::writeSourceMapProlog() {
- *sourceMap << "{\"version\":3,\"sources\":[";
+ *sourceMap << "{\"version\":3,";
+
+ for (const auto& section : wasm->customSections) {
+ if (section.name == BinaryConsts::CustomSections::BuildId) {
+ U32LEB ret;
+ size_t pos = 0;
+ ret.read([&]() { return section.data[pos++]; });
+
+ if (section.data.size() != pos + ret.value) {
+ std::cerr
+ << "warning: build id section with an incorrect size detected!\n";
+ break;
+ }
+
+ *sourceMap << "\"debugId\":\"";
+ for (size_t i = pos; i < section.data.size(); i++) {
+ *sourceMap << std::setfill('0') << std::setw(2) << std::hex
+ << static_cast<int>(static_cast<uint8_t>(section.data[i]));
+ }
+ *sourceMap << "\",";
+ break;
+ }
+ }
+
+ *sourceMap << "\"sources\":[";
for (size_t i = 0; i < wasm->debugInfoFileNames.size(); i++) {
if (i > 0) {
*sourceMap << ",";
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index ae70e4a22..d138e4226 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -36,6 +36,7 @@ const char* Dylink = "dylink";
const char* Dylink0 = "dylink.0";
const char* Linking = "linking";
const char* Producers = "producers";
+const char* BuildId = "build_id";
const char* TargetFeatures = "target_features";
const char* AtomicsFeature = "atomics";
const char* BulkMemoryFeature = "bulk-memory";