Skip to content

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

Closed
axic opened this issue Jun 6, 2016 · 9 comments
Closed

Library placeholders in the bytecode (not well documented) #635

axic opened this issue Jun 6, 2016 · 9 comments

Comments

@axic
Copy link
Member

axic commented Jun 6, 2016

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

@chriseth
Copy link
Contributor

chriseth commented Jun 7, 2016

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.

@VoR0220
Copy link
Member

VoR0220 commented Jun 7, 2016

so...this is being changed?

@chriseth
Copy link
Contributor

chriseth commented Jun 8, 2016

Yes.

@VoR0220
Copy link
Member

VoR0220 commented Jun 9, 2016

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.

@chriseth
Copy link
Contributor

chriseth commented Jun 9, 2016

@VoR0220
Copy link
Member

VoR0220 commented Jun 9, 2016

so in other words now it will replace them with a hex representation of the library's name?

@chriseth
Copy link
Contributor

chriseth commented Jun 10, 2016

It will just inject the libraries name into the hex making it non-hex. It is all explained in the docs.

@redsquirrel
Copy link
Contributor

Will the underscores still be used? It's convenient to have those
underscores because you can auto-detect unlinked libraries, like this:
https://github.com/ethereum/browser-solidity/blob/master/src/universal-dapp.js#L542

On Fri, Jun 10, 2016 at 2:43 AM, chriseth [email protected] wrote:

It will just inject the libraries name into the hex making it non-hex.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#635 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAAJ0NaWzMCsGlEGvJLT7EDF6tuyCH-Kks5qKRWYgaJpZM4IvZgG
.

@chriseth
Copy link
Contributor

Closing in favour of #863

axic pushed a commit that referenced this issue Nov 20, 2018
Clearer explanation of revealing a bid late
axic pushed a commit to ipsilon/solidity that referenced this issue Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants