This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch][rfc] Giving plugins access to gold's file views


Rafael Avila de Espindola <respindola@mozilla.com> writes:

> *) It is only possible to ask for views of the entire file. The reason
> is that during LTO it is more efficient to merge files as we read
> them, so I didn't see a lot of reason to add support to mapping only
> parts of a file. In any case, I can add an offset and size argument if
> you want.
>
> *) The call works when called from the claim_file hook or from the
> all_symbols_read hook. I only tested the first one, but making it work
> on both cases looked easy.
>
> *) The plugin has no guarantees of how long the view will be valid
> for. It it wants to see the view in a subsequent callback, it has to
> ask for it again.
>
> *) The "aligned" and "cache" arguments are not exposed. Since the
> behaviour with aligned set to true is the copy in into anonymous
> memory, the plugin can just read the file itself. The "cache" value is
> always set to false. If the plugin claims the file, it will probably
> use it all at once. If it doesn't and gold then asks for a cached
> view, find_or_make_view correctly calls set_cache.
>
> If you are OK with this, I will finish it up (comments, interface
> documentation and ChangeLog), split the bits that have to be committed
> in gcc first and send an updated version for review.

I'm OK with this approach.

We already expose the file descriptor in the plugin interface, so this
is just for efficiency, right?

> +  if (this->objects_.size() == handle) {
> +    // We are being called from the claim_file hook.
> +    const struct ld_plugin_input_file &f = this->plugin_input_file_;
> +    offset = f.offset;
> +    filesize = f.filesize;
> +    input_file = this->input_file_;
> +  } else {
> +    // An already claimed file.
> +    Pluginobj* obj = this->object(handle);
> +    if (obj == NULL)
> +      return LDPS_BAD_HANDLE;
> +    offset = obj->offset();
> +    filesize = obj->filesize();
> +    input_file = obj->input_file();
> +  }

Braces need to be GNU style.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]