assembly section equivalents

25 views
Skip to first unread message

yowl yowlxx

unread,
Dec 13, 2019, 12:24:11 PM12/13/19
to emscripten-discuss
Hi,

I'm porting some code to wasm, and wondered if there was anything equivalent to

extern char __managedcode_a __asm("section$start$__TEXT$__managedcode");
extern char __managedcode_z __asm("section$end$__TEXT$__managedcode")

?

This is getting the start and end of code section in memory, so I guess the start will always be 0, but the end?  I could do 0xffffffff which might be ok for my purposes, but is there anything like the actual end of the wasm code?

Thomas Lively

unread,
Dec 13, 2019, 12:33:21 PM12/13/19
to emscripte...@googlegroups.com
WebAssembly's code does not live in linear memory, so instructions and functions do not have addresses at all. You could make up some numbers to make your code work, but you will never be able to read the code out of memory.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/ef3f23a8-33d1-463e-9de4-50725eef2624%40googlegroups.com.

yowl yowlxx

unread,
Dec 13, 2019, 12:55:40 PM12/13/19
to emscripten-discuss
Thanks, I dont need to read it, and the virtual memory addresses are what I want.  Are you saying there is no equivalent of a program counter?


On Friday, December 13, 2019 at 12:33:21 PM UTC-5, Thomas Lively wrote:
WebAssembly's code does not live in linear memory, so instructions and functions do not have addresses at all. You could make up some numbers to make your code work, but you will never be able to read the code out of memory.

On Fri, Dec 13, 2019 at 9:24 AM yowl yowlxx <scot...@gmail.com> wrote:
Hi,

I'm porting some code to wasm, and wondered if there was anything equivalent to

extern char __managedcode_a __asm("section$start$__TEXT$__managedcode");
extern char __managedcode_z __asm("section$end$__TEXT$__managedcode")

?

This is getting the start and end of code section in memory, so I guess the start will always be 0, but the end?  I could do 0xffffffff which might be ok for my purposes, but is there anything like the actual end of the wasm code?

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

Thomas Lively

unread,
Dec 13, 2019, 2:01:01 PM12/13/19
to emscripte...@googlegroups.com
Yes, that's correct. WebAssembly is a Harvard architecture, so there is no program counter. In Emscripten there are APIs to parse the WebAssembly binary and compute fake PC values as offsets into the binary, but I do not recommend using them for anything. They are very low-level and heavyweight. They were essentially added as a hack to make AddressSanitizer error reporting work correctly.

On Fri, Dec 13, 2019 at 9:55 AM yowl yowlxx <scot...@gmail.com> wrote:
Thanks, I dont need to read it, and the virtual memory addresses are what I want.  Are you saying there is no equivalent of a program counter?

On Friday, December 13, 2019 at 12:33:21 PM UTC-5, Thomas Lively wrote:
WebAssembly's code does not live in linear memory, so instructions and functions do not have addresses at all. You could make up some numbers to make your code work, but you will never be able to read the code out of memory.

On Fri, Dec 13, 2019 at 9:24 AM yowl yowlxx <scot...@gmail.com> wrote:
Hi,

I'm porting some code to wasm, and wondered if there was anything equivalent to

extern char __managedcode_a __asm("section$start$__TEXT$__managedcode");
extern char __managedcode_z __asm("section$end$__TEXT$__managedcode")

?

This is getting the start and end of code section in memory, so I guess the start will always be 0, but the end?  I could do 0xffffffff which might be ok for my purposes, but is there anything like the actual end of the wasm code?

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/b4bb2d64-f5e4-4369-8b2d-61217cdf09a7%40googlegroups.com.

yowl yowlxx

unread,
Dec 13, 2019, 2:09:43 PM12/13/19
to emscripten-discuss
I see, thanks for the link!


On Friday, December 13, 2019 at 2:01:01 PM UTC-5, Thomas Lively wrote:
Yes, that's correct. WebAssembly is a Harvard architecture, so there is no program counter. In Emscripten there are APIs to parse the WebAssembly binary and compute fake PC values as offsets into the binary, but I do not recommend using them for anything. They are very low-level and heavyweight. They were essentially added as a hack to make AddressSanitizer error reporting work correctly.

On Fri, Dec 13, 2019 at 9:55 AM yowl yowlxx <scot...@gmail.com> wrote:
Thanks, I dont need to read it, and the virtual memory addresses are what I want.  Are you saying there is no equivalent of a program counter?

On Friday, December 13, 2019 at 12:33:21 PM UTC-5, Thomas Lively wrote:
WebAssembly's code does not live in linear memory, so instructions and functions do not have addresses at all. You could make up some numbers to make your code work, but you will never be able to read the code out of memory.

On Fri, Dec 13, 2019 at 9:24 AM yowl yowlxx <scot...@gmail.com> wrote:
Hi,

I'm porting some code to wasm, and wondered if there was anything equivalent to

extern char __managedcode_a __asm("section$start$__TEXT$__managedcode");
extern char __managedcode_z __asm("section$end$__TEXT$__managedcode")

?

This is getting the start and end of code section in memory, so I guess the start will always be 0, but the end?  I could do 0xffffffff which might be ok for my purposes, but is there anything like the actual end of the wasm code?

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages