From bfcd0a10864e7e70b7aaad59141dffb9d29f05fe Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Tue, 12 Mar 2024 01:51:30 +0900 Subject: [PATCH] Add support for new WASM_SEGMENT_FLAG_RETAIN segment flag (#2399) See https://github.com/llvm/llvm-project/pull/81539 --- include/wabt/common.h | 1 + src/binary-reader-objdump.cc | 4 ++++ test/binary/linking-section.txt | 8 ++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/wabt/common.h b/include/wabt/common.h index 4a26a1664..f44ad25e9 100644 --- a/include/wabt/common.h +++ b/include/wabt/common.h @@ -333,6 +333,7 @@ enum class ComdatType { #define WABT_SEGMENT_FLAG_STRINGS 0x1 #define WABT_SEGMENT_FLAG_TLS 0x2 +#define WASM_SEGMENT_FLAG_RETAIN 0x4 #define WABT_SEGMENT_FLAG_MAX 0xff enum class SymbolVisibility { diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc index 488ff1d23..c3be4562b 100644 --- a/src/binary-reader-objdump.cc +++ b/src/binary-reader-objdump.cc @@ -2206,6 +2206,10 @@ Result BinaryReaderObjdump::PrintSegmentFlags(uint32_t flags) { PrintDetails(" TLS"); flags &= ~WABT_SEGMENT_FLAG_TLS; } + if (flags & WASM_SEGMENT_FLAG_RETAIN) { + PrintDetails(" RETAIN"); + flags &= ~WASM_SEGMENT_FLAG_RETAIN; + } if (flags != 0) { PrintDetails(" unknown_flags=%#x", flags); } diff --git a/test/binary/linking-section.txt b/test/binary/linking-section.txt index 3ba79895c..a530f1c2a 100644 --- a/test/binary/linking-section.txt +++ b/test/binary/linking-section.txt @@ -51,13 +51,16 @@ section("linking") { metadata_version[2] section(LINKING_SEGMENT_INFO) { - count[2] + count[3] str("data1") p2align[2] flags[1] str("data2") p2align[3] flags[10] + str("data3") + p2align[2] + flags[4] } section(LINKING_INIT_FUNCTIONS) { @@ -153,9 +156,10 @@ Data[2]: - 000000a: 6261 72 bar Custom: - name: "linking" - - segment info [count=2] + - segment info [count=3] - 0: data1 p2align=2 [ STRINGS ] - 1: data2 p2align=3 [ TLS unknown_flags=0x8 ] + - 2: data3 p2align=2 [ RETAIN ] - init functions [count=2] - 1: priority=5 - 0: priority=6