-
Notifications
You must be signed in to change notification settings - Fork 1
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
Function addresses #1
Comments
yes, the intention is to add function addresses but I didn't get up to it yet. that's why it doesn't have a check-mark. the idea is that you can query the address of a function and then pack arguments to it so that you can invoke it dynamically. it needs a bridge between crefl to something like libffi. the resulting code will be much simpler than libffi is currently because the type signature does not need to be built up by hand. I have some code for this but it's not yet cleaned up enough to commit. instead of calling
where one passes the we have a metadata merge step with crefltool, which is our version of a link, and from that we generate an array containing the runtime metadata that is linked into the final binary. at that stage, before the final link, we could also (optionally) create an array that takes the addresses of functions and global variables. I say optionally because taking the address of objects may change the code that is generated. the resulting ffi code might look like something like this code below. considerably simpler than libffi. note there is a challenge to lookup up a function declaration because we essentially need to parse an unambiguous function signature. what I have below is sufficient for C but does not handle type overloading. i'd actually like to be able to expose a C API to to some basic C++ metadata but that would require a more sophisticated way to get a reference to a function or member function than simply using its mangled name. ideally it might look a bit like a Rust function decl. e.g. the
let me know and I can share you some of this stuff out-of-band. as it's not quite at the level of committing to the repo yet. |
I've seen you've listed function addresses as a todo item in your list.
What do you mean by this ?
I'd like to make a an automated REPL system for esp-idf (large) api in order to be able to call the functions declared in the API, so I'm trying to make use of crefl for this.
Ideally, I need to link the function's name to their addresses in the final binary, so I can create a function pointer and jump to them.
I've though of doing this this way:
Right now, this idea should work without crepl listing function addresses since taking the function address is done by the compiler, but it has numerous drawbacks:
If crefl had the function address in the database (needs to be added at a later step, since these address are only accessible/valid once the object is linked, and compilation and linking will likely not use clang), then we won't need to store all the reflection in the binary, and it could be loaded at runtime. Also a mode to create a struct's memory at runtime would be very useful.
The text was updated successfully, but these errors were encountered: