Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

When building relocatable code lookup function addresses dynamically via fp$foo functions#259

Merged
sbc100 merged 2 commits intoincomingfrom
function_addresses
Sep 12, 2019
Merged

When building relocatable code lookup function addresses dynamically via fp$foo functions#259
sbc100 merged 2 commits intoincomingfrom
function_addresses

Conversation

@sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Apr 27, 2019

This means that the dynamic linker then assigned function pointers
and both main module and side module use fp$foo accessors to lookup
function addresses, just like they do for global addresses.

This allows the test_dylink_function_pointer_equality test in emscripten
to pass.

See emscripten-core/emscripten#8268.

@sbc100 sbc100 requested a review from kripken April 27, 2019 00:16
}
Out << "],";

Out << "\"externFunctions\": [";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't externs enough for the purpose here - idn't externFunctions duplicating part of it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

externs is for external global data and we want to be able to handle the corresponding g$ and fp$ helpers separately.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't emscripten.py tell which of the externs are functions and which are globals? Then it could create the helpers there? Or is this just easier to do here?

Copy link
Collaborator Author

@sbc100 sbc100 Sep 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. IIUC emscripten.py gets all the info it has from the metadata so we need to encode this somehow.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could instead list them in the declares sections with the fp$ prefix so we would know which decleres we of this type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good either way - you know this code the best at this point.

@sbc100 sbc100 force-pushed the function_addresses branch from eb38dd4 to a4dce6f Compare September 4, 2019 04:19
sbc100 added a commit to emscripten-core/emscripten that referenced this pull request Sep 4, 2019
There is upstream fastcomp change coming which addresses function
pointer equality between wasm modules (i.e. SIDE_MODULE/MAIN_MODULE):
emscripten-core/emscripten-fastcomp#259

This change prepares for that change by handling the new
externFunctions metadata attribute.  This new key represents a list
of all non-static functions in a relocatable module which are address
taken.  The module will call fp$<name>() in order to find out the
runtime address (table entry) for such functions.

Once both these changes land they they will fix #8268.
@sbc100 sbc100 force-pushed the function_addresses branch from a4dce6f to 1a34ed0 Compare September 4, 2019 21:33
sbc100 added a commit to emscripten-core/emscripten that referenced this pull request Sep 5, 2019
There is upstream fastcomp change coming which addresses function
pointer equality between wasm modules (i.e. SIDE_MODULE/MAIN_MODULE):
emscripten-core/emscripten-fastcomp#259

This change prepares for that change by handling the new
externFunctions metadata attribute.  This new key represents a list
of all non-static functions in a relocatable module which are address
taken.  The module will call fp$<name>() in order to find out the
runtime address (table entry) for such functions.

Once both these changes land they they will fix #8268.
sbc100 added a commit to emscripten-core/emscripten that referenced this pull request Sep 5, 2019
There is upstream fastcomp change coming which addresses function
pointer equality between wasm modules (i.e. SIDE_MODULE/MAIN_MODULE):
emscripten-core/emscripten-fastcomp#259

This change prepares for that change by handling the new
externFunctions metadata attribute.  This new key represents a list
of all non-static functions in a relocatable module which are address
taken.  The module will call fp$<name>() in order to find out the
runtime address (table entry) for such functions.

Once both these changes land they they will fix #8268.
sbc100 added a commit to emscripten-core/emscripten that referenced this pull request Sep 5, 2019
)

There is upstream fastcomp change coming which addresses function
pointer equality between wasm modules (i.e. SIDE_MODULE/MAIN_MODULE):
emscripten-core/emscripten-fastcomp#259

This change prepares for that change by handling the new
externFunctions metadata attribute.  This new key represents a list
of all non-static functions in a relocatable module which are address
taken.  The module will call fp$<name>() in order to find out the
runtime address (table entry) for such functions.

Once both these changes land they they will fix #8268.
…via `fp$foo` functions

This means that the dynamic linker then assigned function pointers
and both main module and side module use `fp$foo` accessors to lookup
function addresses, just like they do for global addresses.

This allows the test_dylink_function_pointer_equality test in emscripten
to pass.

See emscripten-core/emscripten#8268.
@sbc100 sbc100 merged commit 6c7e775 into incoming Sep 12, 2019
@sbc100 sbc100 deleted the function_addresses branch September 12, 2019 00:13
sbc100 added a commit to emscripten-core/emscripten that referenced this pull request Sep 12, 2019
sbc100 added a commit to emscripten-core/emscripten that referenced this pull request Sep 12, 2019
belraquib pushed a commit to belraquib/emscripten that referenced this pull request Dec 23, 2020
…scripten-core#9393)

There is upstream fastcomp change coming which addresses function
pointer equality between wasm modules (i.e. SIDE_MODULE/MAIN_MODULE):
emscripten-core/emscripten-fastcomp#259

This change prepares for that change by handling the new
externFunctions metadata attribute.  This new key represents a list
of all non-static functions in a relocatable module which are address
taken.  The module will call fp$<name>() in order to find out the
runtime address (table entry) for such functions.

Once both these changes land they they will fix emscripten-core#8268.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants