Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read-only static data location? #10315

Open
kripken opened this issue Jan 29, 2020 · 5 comments
Open

Read-only static data location? #10315

kripken opened this issue Jan 29, 2020 · 5 comments
Labels

Comments

@kripken
Copy link
Member

kripken commented Jan 29, 2020

A user hit a case where static memory was being trashed it seems. Talking with @dschuff , if we knew where read-only static data was, we could make SAFE_HEAP check for any writes to there.

Does the linker have that information? We need to differentiate the read-only data from the read-write and bss sections, basically. cc @sbc100 @tlively

@sbc100
Copy link
Collaborator

sbc100 commented Jan 29, 2020

Yes this should certainly be do-able. I think the linker should provide a symbol for that, although I don't think we do today.

It does looks like we already put the .rodata segment first when linking the final binary.

@sbc100
Copy link
Collaborator

sbc100 commented Jan 30, 2020

Sadly it looks like we can find the end of the data and end of the bss using some old legacy C symbols:

NAME
       etext, edata, end - end of program segments

SYNOPSIS
       extern etext;
       extern edata;
       extern end;

DESCRIPTION
       The addresses of these symbols indicate the end of various program segments:

       etext  This is the first address past the end of the text segment (the program code).

       edata  This is the first address past the end of the initialized data segment.

       end    This is the first address past the end of the uninitialized data segment (also known as the BSS segment).

wasm-ld supports these but sadly they are not what we want here.

We can also get the start and end of any sections that is a C identifier. So if you put a data symbols in sectiion foo the linker will magically create __start_foo and __end_foo symbols on demand. However this is not true for section like the builtin ones that are C identifiers (e.g. .rodata which is the one we want here.).

So I think we either need to create a new magic symbol for erodata or we find some way to safely extend the __start_/__end_ symbol creation to non-C-identifiers that is safe against collisions.

@stale
Copy link

stale bot commented Jan 30, 2021

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

@stale stale bot added the wontfix label Jan 30, 2021
@dschuff
Copy link
Member

dschuff commented Feb 2, 2021

This still sounds like it might be useful.

@stale stale bot removed the wontfix label Feb 2, 2021
@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

@stale stale bot added the wontfix label Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants