-
Notifications
You must be signed in to change notification settings - Fork 156
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
objcopy --redefine-sym #148
Comments
Definitely open to adding something like this, but I don't have much idea of what the ideal API would look like. The problem is there is a wide range of possible transforms, so it would be nice if the API was flexible enough to handle unforseen needs, instead of limiting to a small number of options. There's a similar problem for the DWARF read/write support in gimli, and for that I've written functions to convert from the read data structures to the write data structures, but currently it doesn't have support for transforming during conversion. Applying transforms is something we do need to support though. |
Im new to Rust, so Im just getting familiar with the limitations. Ideally for symbol name rewriting, a function/closure/lambda could be provided to take the old name (and other args such as target object format & mach arch) and provide the new desired sym name. That could cover the mangling use-case as well. As functions are not first class entities in Rust, this might mean a closure is the only very flexible option. If that doesnt work, a table of match->rewrite-pattern would also work, and be almost as good. |
If you want to do the transform via callbacks, then you probably want to do this via a trait that has a method for each possible callback. My concern with this is it restricts the control flow of the objcopy, which means it may not be flexible enough. It would be fine as a starting point until something better is needed though.
The usual way is to use one of the
The mangling use-case is a bit different. It's not intended for objcopy, because the symbols in the source object file will already be mangled. Instead it's for the initial codegen, where the name of the symbol will be from the source language, and it needs to be mangled depending on which file format it is outputting to. |
The objconv utility may give some ideas for the sort of transformations that are useful to support. |
I ran into a use-case for this feature, it looks like I'll also end up substantially copying the objcopy example. Based on just a brief glance at the docs and source, I'm wondering if it would make sense to extend the |
Depending on which editing operations you need, it could require require significant changes to support editing If you are able to elaborate more on your use case then that would be helpful. |
We are interested in reimplementing (parts of) In the conda ecosystem we need I am wondering if |
So that would be https://github.com/NixOS/patchelf and https://github.com/opensource-apple/cctools/blob/master/misc/install_name_tool.c (or https://github.com/tpoechtrager/cctools-port/blob/986-ld64-711/cctools/misc/install_name_tool.c). It would be possible to use |
Thanks for your thoughts @philipc – do you think it would be more adequate to try to use |
Since you only need to patch the file, they should both work. (If you needed to write the whole file then |
Hi @wolfv , I've created Rust bindings for the patchelf code at patchelf-rs. I hope this will be useful for you. |
Awesome @spinpx – the API looks nice! I think this can be useful also for testing the potential Rust implementation :) |
I've started work on converting the I've decided not to support this kind of thing in |
#618 provides the ELF support for this, including library APIs and a CLI for much of the patchelf functionality. |
indygreg/PyOxidizer#183 contains a lot of boilerplate code to write a object file, substantially copied from https://github.com/gimli-rs/object/blob/master/examples/objcopy.rs .
It would be nice if there was a simple API to achieve the same, with high-level transform operations selected and then the reconstruction iteration process left for
object
& friends to perform.In my case the transform I need is renaming of one sym from
PyInit_*
toPyInit_foo_baz
. This is the same asobjcopy --redefine-sym old=new
, and it is a bit similar to theMangling
use-case.The text was updated successfully, but these errors were encountered: