-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Library placeholders in the bytecode (not well documented) #635
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
Comments
Yes, this will lead to truncation. Please keep in mind that this way of linking is only a workaround. The proper way of linking would be to use LinkerObjects. They are already present in solc, we need to also make them available in solc-js - I'm currently working towards this. |
so...this is being changed? |
Yes. |
what are we changing them to instead in regards to the named placeholders for a library? Please do let me know...it kind of effects current work. |
It will be replaced by something like this here: https://github.com/ethereum/solidity/blob/c492d9be00c843b8390959bd9f203c4047cb9f69/libevmasm/LinkerObject.h |
so in other words now it will replace them with a hex representation of the library's name? |
It will just inject the libraries name into the hex making it non-hex. It is all explained in the docs. |
Will the underscores still be used? It's convenient to have those On Fri, Jun 10, 2016 at 2:43 AM, chriseth [email protected] wrote:
|
Closing in favour of #863 |
Clearer explanation of revealing a bid late
Placeholders in the format of library name pre/postfixed with underscores (i.e.
__LibraryName...__
) are used to indicate where the 20 byte library address must be put in.This means, in many cases library names are truncated.
The documentation isn't explaining it well. It suggests there are 6 trailing underscores.
On http://solidity.readthedocs.io/en/latest/contracts.html#libraries:
If the addresses are not given as arguments to the compiler, the compiled hex code will contain placeholders of the form __Set______ (where Set is the name of the library). The address can be filled manually by replacing all those 40 symbols by the hex encoding of the address of the library contract.
On http://solidity.readthedocs.io/en/latest/miscellaneous.html:
If your contracts use libraries, you will notice that the bytecode contains substrings of the form __LibraryName______.
If solc is called with the option --link, all input files are interpreted to be unlinked binaries (hex-encoded) in the __LibraryName____-format given above and are linked in-place (if the input is read from stdin, it is written to stdout).
Does it make sense having this information in multiple places?
cc @Denton-L @chriseth
The text was updated successfully, but these errors were encountered: