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: Pass plugin as target for "ar --plugin" when opening a BFD file


On 15 September 2010 09:37, H.J. Lu <hongjiu.lu@intel.com> wrote:
> "ar --plugin" should pass "plugin" as target when opening a BFD file,
> instead of replying on setting envriomental variable GNUTARGET to
> "plugin". ÂOK to install?

I cannot approve this, but it would really make using the plugin with
gcc's LTO a lot easier :-)

Thanks,
Rafael


> Thanks.
>
>
> H.J.
> ---
> 2010-09-15 ÂH.J. Lu Â<hongjiu.lu@intel.com>
>
> Â Â Â Â* ar.c (plugin_target): New.
> Â Â Â Â(main): Set plugin_target to "plugin" for --plugin.
> Â Â Â Â(open_inarch): Initialize target to plugin_target.
> Â Â Â Â(replace_members): Pass plugin_target to ar_emul_replace
> Â Â Â Âand ar_emul_append.
>
> Â Â Â Â* binemul.h (ar_emul_append): Add a target argument.
> Â Â Â Â(ar_emul_default_append): Likewise.
> Â Â Â Â(ar_emul_replace): Likewise.
> Â Â Â Â(ar_emul_default_replace): Likewise.
> Â Â Â Â(bin_emulation_xfer_struct): Add a target argument to
> Â Â Â Âar_append and ar_replace.
>
> Â Â Â Â* binemul.c (ar_emul_append): Updated. ÂPass target to bfd_openr.
> Â Â Â Â(do_ar_emul_default_append): Likewise.
> Â Â Â Â(ar_emul_default_append): Likewise.
> Â Â Â Â(ar_emul_replace): Likewise.
> Â Â Â Â(ar_emul_default_replace): Likewise.
>
> diff --git a/binutils/ar.c b/binutils/ar.c
> index fd1b9ec..4c765ca 100644
> --- a/binutils/ar.c
> +++ b/binutils/ar.c
> @@ -132,6 +132,8 @@ static bfd_boolean full_pathname = FALSE;
> Â/* Whether to create a "thin" archive (symbol index only -- no files). Â*/
> Âstatic bfd_boolean make_thin_archive = FALSE;
>
> +static const char *plugin_target = NULL;
> +
> Âint interactive = 0;
>
> Âstatic void
> @@ -472,6 +474,8 @@ main (int argc, char **argv)
>
> Â Â Â arg_index += 2;
> Â Â Â arg_ptr = argv[arg_index];
> +
> + Â Â Âplugin_target = "plugin";
> Â#else
> Â Â Â fprintf (stderr, _("sorry - this program has been built without plugin support\n"));
> Â Â Â xexit (1);
> @@ -716,7 +720,7 @@ open_inarch (const char *archive_filename, const char *file)
>
> Â bfd_set_error (bfd_error_no_error);
>
> - Âtarget = NULL;
> + Âtarget = plugin_target;
>
> Â if (stat (archive_filename, &sbuf) != 0)
> Â Â {
> @@ -747,7 +751,7 @@ open_inarch (const char *archive_filename, const char *file)
> Â Â Â Â{
> Â Â Â Â Âbfd *obj;
>
> - Â Â Â Â obj = bfd_openr (file, NULL);
> + Â Â Â Â obj = bfd_openr (file, target);
> Â Â Â Â Âif (obj != NULL)
> Â Â Â Â Â Â{
> Â Â Â Â Â Â Âif (bfd_check_format (obj, bfd_object))
> @@ -1205,7 +1209,7 @@ replace_members (bfd *arch, char **files_to_move, bfd_boolean quick)
> Â Â Â Â Â Â Â Â Âafter_bfd = get_pos_bfd (&arch->archive_next, pos_after,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â current->filename);
> Â Â Â Â Â Â Â Â Âif (ar_emul_replace (after_bfd, *files_to_move,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âverbose))
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âplugin_target, verbose))
> Â Â Â Â Â Â Â Â Â Â{
> Â Â Â Â Â Â Â Â Â Â Â/* Snip out this entry from the chain. Â*/
> Â Â Â Â Â Â Â Â Â Â Â*current_ptr = (*current_ptr)->archive_next;
> @@ -1221,8 +1225,8 @@ replace_members (bfd *arch, char **files_to_move, bfd_boolean quick)
> Â Â Â /* Add to the end of the archive. Â*/
> Â Â Â after_bfd = get_pos_bfd (&arch->archive_next, pos_end, NULL);
>
> - Â Â Âif (ar_emul_append (after_bfd, *files_to_move, verbose,
> - Â Â Â Â Â Â Â Â Â Â Â Â Âmake_thin_archive))
> + Â Â Âif (ar_emul_append (after_bfd, *files_to_move, plugin_target,
> + Â Â Â Â Â Â Â Â Â Â Â Â verbose, make_thin_archive))
> Â Â Â Âchanged = TRUE;
>
> Â Â next_file:;
> diff --git a/binutils/binemul.c b/binutils/binemul.c
> index 2931bda..35587db 100644
> --- a/binutils/binemul.c
> +++ b/binutils/binemul.c
> @@ -39,19 +39,19 @@ ar_emul_default_usage (FILE *fp)
> Â}
>
> Âbfd_boolean
> -ar_emul_append (bfd **after_bfd, char *file_name, bfd_boolean verbose,
> - Â Â Â Â Â Â Â Âbfd_boolean flatten)
> +ar_emul_append (bfd **after_bfd, char *file_name, const char *target,
> + Â Â Â Â Â Â Â bfd_boolean verbose, bfd_boolean flatten)
> Â{
> Â if (bin_dummy_emulation.ar_append)
> - Â Âreturn bin_dummy_emulation.ar_append (after_bfd, file_name, verbose,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âflatten);
> + Â Âreturn bin_dummy_emulation.ar_append (after_bfd, file_name, target,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â verbose, flatten);
>
> Â return FALSE;
> Â}
>
> Âstatic bfd_boolean
> Âdo_ar_emul_default_append (bfd **after_bfd, bfd *new_bfd,
> - Â Â Â Â Â Â Â Â Â Â Â bfd_boolean verbose, bfd_boolean flatten)
> + Â Â Â Â Â Â Â Â Â Â Â Â Âbfd_boolean verbose, bfd_boolean flatten)
> Â {
> Â /* When flattening, add the members of an archive instead of the
> Â Â Âarchive itself. Â*/
> @@ -84,32 +84,35 @@ do_ar_emul_default_append (bfd **after_bfd, bfd *new_bfd,
>
> Âbfd_boolean
> Âar_emul_default_append (bfd **after_bfd, char *file_name,
> - Â Â Â Â Â Â Â Â Â Â Â bfd_boolean verbose, bfd_boolean flatten)
> + Â Â Â Â Â Â Â Â Â Â Â const char *target, bfd_boolean verbose,
> + Â Â Â Â Â Â Â Â Â Â Â bfd_boolean flatten)
> Â{
> Â bfd *new_bfd;
>
> - Ânew_bfd = bfd_openr (file_name, NULL);
> + Ânew_bfd = bfd_openr (file_name, target);
> Â AR_EMUL_ELEMENT_CHECK (new_bfd, file_name);
> Â return do_ar_emul_default_append (after_bfd, new_bfd, verbose, flatten);
> Â}
>
> Âbfd_boolean
> -ar_emul_replace (bfd **after_bfd, char *file_name, bfd_boolean verbose)
> +ar_emul_replace (bfd **after_bfd, char *file_name, const char *target,
> + Â Â Â Â Â Â Â Âbfd_boolean verbose)
> Â{
> Â if (bin_dummy_emulation.ar_replace)
> - Â Âreturn bin_dummy_emulation.ar_replace (after_bfd, file_name, verbose);
> + Â Âreturn bin_dummy_emulation.ar_replace (after_bfd, file_name,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âtarget, verbose);
>
> Â return FALSE;
> Â}
>
> Âbfd_boolean
> Âar_emul_default_replace (bfd **after_bfd, char *file_name,
> - Â Â Â Â Â Â Â Â Â Â Â Âbfd_boolean verbose)
> + Â Â Â Â Â Â Â Â Â Â Â Âconst char *target, bfd_boolean verbose)
> Â{
> Â bfd *temp;
>
> Â temp = *after_bfd;
> - Â*after_bfd = bfd_openr (file_name, NULL);
> + Â*after_bfd = bfd_openr (file_name, target);
>
> Â AR_EMUL_ELEMENT_CHECK (*after_bfd, file_name);
> Â AR_EMUL_REPLACE_PRINT_VERBOSE (verbose, file_name);
> diff --git a/binutils/binemul.h b/binutils/binemul.h
> index 1b02015..f85cc09 100644
> --- a/binutils/binemul.h
> +++ b/binutils/binemul.h
> @@ -28,11 +28,14 @@
>
> Âextern void ar_emul_usage (FILE *);
> Âextern void ar_emul_default_usage (FILE *);
> -extern bfd_boolean ar_emul_append (bfd **, char *, bfd_boolean, bfd_boolean);
> -extern bfd_boolean ar_emul_default_append (bfd **, char *, bfd_boolean,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bfd_boolean);
> -extern bfd_boolean ar_emul_replace (bfd **, char *, bfd_boolean);
> -extern bfd_boolean ar_emul_default_replace (bfd **, char *, bfd_boolean);
> +extern bfd_boolean ar_emul_append (bfd **, char *, const char *,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âbfd_boolean, bfd_boolean);
> +extern bfd_boolean ar_emul_default_append (bfd **, char *, const char *,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âbfd_boolean, bfd_boolean);
> +extern bfd_boolean ar_emul_replace (bfd **, char *, const char *,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bfd_boolean);
> +extern bfd_boolean ar_emul_default_replace (bfd **, char *,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â const char *, bfd_boolean);
> Âextern bfd_boolean ar_emul_parse_arg (char *);
> Âextern bfd_boolean ar_emul_default_parse_arg (char *);
>
> @@ -55,8 +58,9 @@ typedef struct bin_emulation_xfer_struct
> Â{
> Â /* Print out the extra options. Â*/
> Â void (* ar_usage) (FILE *fp);
> - Âbfd_boolean (* ar_append) (bfd **, char *, bfd_boolean, bfd_boolean);
> - Âbfd_boolean (* ar_replace) (bfd **, char *, bfd_boolean);
> + Âbfd_boolean (* ar_append) (bfd **, char *, const char *, bfd_boolean,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Âbfd_boolean);
> + Âbfd_boolean (* ar_replace) (bfd **, char *, const char *, bfd_boolean);
> Â bfd_boolean (* ar_parse_arg) (char *);
> Â}
> Âbin_emulation_xfer_type;
>



-- 
Rafael Ãvila de EspÃndola


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