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?
for NULL function pointer?
YAMAMOTO Takashi said:
for NULL function pointer?
I am not familiar with this case. Can you provide more context here?
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.
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!
Wilson Wang has marked this topic as resolved.
Last updated: Dec 23 2024 at 12:05 UTC