Skip to content

Commit

Permalink
Add support for new WASM_SYMBOL_ABS symbol flag (WebAssembly#2305)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 authored Nov 28, 2023
1 parent 9944d92 commit bcd03e8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
3 changes: 2 additions & 1 deletion include/wabt/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ enum class ComdatType {
#define WABT_SYMBOL_FLAG_EXPLICIT_NAME 0x40
#define WABT_SYMBOL_FLAG_NO_STRIP 0x80
#define WABT_SYMBOL_FLAG_TLS 0x100
#define WABT_SYMBOL_FLAG_MAX 0x1ff
#define WABT_SYMBOL_FLAG_ABS 0x200
#define WABT_SYMBOL_FLAG_MAX 0x3ff

#define WABT_SEGMENT_FLAG_STRINGS 0x1
#define WABT_SEGMENT_FLAG_TLS 0x2
Expand Down
15 changes: 12 additions & 3 deletions src/binary-reader-objdump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2171,6 +2171,10 @@ Result BinaryReaderObjdump::PrintSymbolFlags(uint32_t flags) {
PrintDetails(" tls");
flags &= ~WABT_SYMBOL_FLAG_TLS;
}
if (flags & WABT_SYMBOL_FLAG_ABS) {
PrintDetails(" abs");
flags &= ~WABT_SYMBOL_FLAG_ABS;
}
if (flags != 0) {
PrintDetails(" unknown_flags=%#x", flags);
}
Expand Down Expand Up @@ -2207,9 +2211,14 @@ Result BinaryReaderObjdump::OnDataSymbol(Index index,
uint32_t size) {
PrintDetails(" - %d: D <" PRIstringview ">", index,
WABT_PRINTF_STRING_VIEW_ARG(name));
if (!(flags & WABT_SYMBOL_FLAG_UNDEFINED))
PrintDetails(" segment=%" PRIindex " offset=%d size=%d", segment, offset,
size);
if (!(flags & WABT_SYMBOL_FLAG_UNDEFINED)) {
if (flags & WABT_SYMBOL_FLAG_ABS) {
PrintDetails(" address=%d size=%d", offset, size);
} else {
PrintDetails(" segment=%" PRIindex " offset=%d size=%d", segment, offset,
size);
}
}
return PrintSymbolFlags(flags);
}

Expand Down
16 changes: 12 additions & 4 deletions test/binary/linking-section.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ section("linking") {
}

section(LINKING_SYMBOL_TABLE) {
num_symbols[5]
num_symbols[6]

type[0]
flags[1]
Expand All @@ -88,6 +88,13 @@ section("linking") {
offset[2]
size[1]

type[1]
flags[leb_i32(512)]
str("absolute_data_sym")
segment[0]
offset[leb_i32(1024)]
size[0]

type[0]
flags[0x10]
index[0]
Expand Down Expand Up @@ -152,12 +159,13 @@ Custom:
- init functions [count=2]
- 1: priority=5 <global_sym>
- 0: priority=6 <func_sym>
- symbol table [count=5]
- symbol table [count=6]
- 0: F <func_sym> func=0 [ binding=weak vis=default ]
- 1: G <global_sym> global=0 [ binding=local vis=default ]
- 2: D <data_sym> segment=1 offset=2 size=1 [ tls binding=global vis=hidden ]
- 3: F <func_sym> func=0 [ undefined binding=global vis=default ]
- 4: T <table_sym> table=0 [ binding=weak vis=default ]
- 3: D <absolute_data_sym> address=1024 size=0 [ abs binding=global vis=default ]
- 4: F <func_sym> func=0 [ undefined binding=global vis=default ]
- 5: T <table_sym> table=0 [ binding=weak vis=default ]
- comdat groups [count=2]
- comdat1: [count=1]
- segment[1] <data2>
Expand Down

0 comments on commit bcd03e8

Please sign in to comment.