Stream: general

Topic: ✔ empty entry in exported table


view this post on Zulip Wilson Wang (Jan 14 2023 at 06:16):

I have a general question regarding wasm code. when I load my .wasm file, I saw that the "__indirect_function_table" has two elements the first one funcref() is nullptr and the second one is my exported func ref. what is the reason for the first element of the "__indirect_function_table" table has 0 store_id?

view this post on Zulip YAMAMOTO Takashi (Jan 14 2023 at 07:05):

for NULL function pointer?

view this post on Zulip Wilson Wang (Jan 14 2023 at 18:17):

YAMAMOTO Takashi said:

for NULL function pointer?

I am not familiar with this case. Can you provide more context here?

view this post on Zulip bjorn3 (Jan 14 2023 at 20:26):

C requires the existence of a NULL pointer which never points to a location where neither memory allocations nor functions exist. This NULL pointer generally has address zero. To satisfy this requirement for function pointers in wasm, the 0th element of the table used for function pointers is reserved using an dummy element. The simplest dummy element is the nullptr value.

view this post on Zulip Wilson Wang (Jan 15 2023 at 01:45):

bjorn3 said:

C requires the existence of a NULL pointer which never points to a location where neither memory allocations nor functions exist. This NULL pointer generally has address zero. To satisfy this requirement for function pointers in wasm, the 0th element of the table used for function pointers is reserved using an dummy element. The simplest dummy element is the nullptr value.

Thanks for the answer!

view this post on Zulip Notification Bot (Jan 15 2023 at 01:46):

Wilson Wang has marked this topic as resolved.


Last updated: Nov 22 2024 at 16:03 UTC