From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28013 invoked by alias); 4 Mar 2011 23:45:04 -0000 Received: (qmail 27995 invoked by uid 22791); 4 Mar 2011 23:45:02 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-iy0-f169.google.com (HELO mail-iy0-f169.google.com) (209.85.210.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 04 Mar 2011 23:44:57 +0000 Received: by iyf13 with SMTP id 13so3154189iyf.0 for ; Fri, 04 Mar 2011 15:44:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.43.51.67 with SMTP id vh3mr1336258icb.379.1299282296079; Fri, 04 Mar 2011 15:44:56 -0800 (PST) Received: by 10.42.60.129 with HTTP; Fri, 4 Mar 2011 15:44:56 -0800 (PST) In-Reply-To: <20110304222623.GF6275@bubble.grove.modra.org> References: <20110302195553.GA27754@intel.com> <4D6EE4C2.3040500@gmail.com> <20110304035134.GW13094@bubble.grove.modra.org> <20110304222623.GF6275@bubble.grove.modra.org> Date: Fri, 04 Mar 2011 23:45:00 -0000 Message-ID: Subject: Re: PATCH: Report plugin symbol status From: "H.J. Lu" To: Dave Korn , binutils@sourceware.org Cc: Alan Modra Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2011-03/txt/msg00074.txt.bz2 On Fri, Mar 4, 2011 at 2:26 PM, Alan Modra wrote: > On Fri, Mar 04, 2011 at 12:46:11PM -0800, H.J. Lu wrote: >> =A0 =A0 =A0 * ld.texinfo: Document --verbose[=3DNUMBER]. >> >> =A0 =A0 =A0 * lexsup.c (ld_options): Update --verbose. >> =A0 =A0 =A0 (parse_args): Set report_plugin_symbols. >> >> =A0 =A0 =A0 * plugin.c (report_plugin_symbols): New. >> =A0 =A0 =A0 (get_symbols): Report plugin symbols if report_plugin_symbols >> =A0 =A0 =A0 is TRUE. >> >> =A0 =A0 =A0 * plugin.h (report_plugin_symbols): New. > > OK, except > > @@ -1337,6 +1338,13 @@ parse_args (unsigned argc, char **argv) > =A0 =A0 =A0 =A0 =A0version_printed =3D TRUE; > =A0 =A0 =A0 =A0 =A0trace_file_tries =3D TRUE; > =A0 =A0 =A0 =A0 =A0overflow_cutoff_limit =3D -2; > + =A0 =A0 =A0 =A0 if (optarg !=3D NULL) > + =A0 =A0 =A0 =A0 =A0 { > + =A0 =A0 =A0 =A0 =A0 =A0 char *end; > + =A0 =A0 =A0 =A0 =A0 =A0 report_plugin_symbols =3D strtoul (optarg, &end= , 0); > + =A0 =A0 =A0 =A0 =A0 =A0 if (*end) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 einfo (_("%P%F: invalid number `%s'\n"), op= targ); > + =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0break; > =A0 =A0 =A0 =A0case 'v': > =A0 =A0 =A0 =A0 =A0ldversion (0); > > I think it would be cleaner to make report_plugin_symbols a boolean > here, rather than leaving it as the --verbose arg and testing for > greater than one later. =A0Alternatively, rename the variable > "verbose_arg" or somesuch. =A0Either way is fine. This is what I checked in. Thanks. --=20 H.J. --- diff --git a/ld/ChangeLog b/ld/ChangeLog index 4f5f2c8..bdf4b01 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,16 @@ +2011-03-04 H.J. Lu + + * ld.texinfo: Document --verbose[=3DNUMBER]. + + * lexsup.c (ld_options): Update --verbose. + (parse_args): Set report_plugin_symbols. + + * plugin.c (report_plugin_symbols): New. + (get_symbols): Report plugin symbols if report_plugin_symbols + is TRUE. + + * plugin.h (report_plugin_symbols): New. + 2011-03-01 H.J. Lu PR ld/12529 diff --git a/ld/ld.texinfo b/ld/ld.texinfo index 9957d03..ed79923 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -1851,13 +1851,14 @@ Normally the linker will generate an error message for each reported unresolved symbol but the option @option{--warn-unresolved-symbols} can change this to a warning. -@kindex --verbose -@cindex verbose +@kindex --verbose[=3D@var{NUMBER}] +@cindex verbose[=3D@var{NUMBER}] @item --dll-verbose -@itemx --verbose +@itemx --verbose[=3D@var{NUMBER}] Display the version number for @command{ld} and list the linker emulations supported. Display which input files can and cannot be opened. Display -the linker script being used by the linker. +the linker script being used by the linker. If the optional @var{NUMBER} +argument > 1, plugin symbol status will also be displayed. @kindex --version-script=3D@var{version-scriptfile} @cindex version script, symbol versions diff --git a/ld/lexsup.c b/ld/lexsup.c index acb63fb..8cf96eb 100644 --- a/ld/lexsup.c +++ b/ld/lexsup.c @@ -560,8 +560,9 @@ static const struct ld_option ld_options[] =3D " ignore-all, report-all, ignore-in-object-files,\n" " ignore-in-shared-libs"), TWO_DASHES }, - { {"verbose", no_argument, NULL, OPTION_VERBOSE}, - '\0', NULL, N_("Output lots of information during link"), TWO_DASHES }, + { {"verbose", optional_argument, NULL, OPTION_VERBOSE}, + '\0', N_("[=3DNUMBER]"), + N_("Output lots of information during link"), TWO_DASHES }, { {"dll-verbose", no_argument, NULL, OPTION_VERBOSE}, /* Linux. */ '\0', NULL, NULL, NO_HELP }, { {"version-script", required_argument, NULL, OPTION_VERSION_SCRIPT }, @@ -1326,6 +1327,14 @@ parse_args (unsigned argc, char **argv) version_printed =3D TRUE; trace_file_tries =3D TRUE; overflow_cutoff_limit =3D -2; + if (optarg !=3D NULL) + { + char *end; + int level =3D strtoul (optarg, &end, 0); + if (*end) + einfo (_("%P%F: invalid number `%s'\n"), optarg); + report_plugin_symbols =3D level > 1; + } break; case 'v': ldversion (0); diff --git a/ld/plugin.c b/ld/plugin.c index 7ac2cb8..a68aea3 100644 --- a/ld/plugin.c +++ b/ld/plugin.c @@ -36,6 +36,9 @@ #include #endif +/* Report plugin symbols. */ +bfd_boolean report_plugin_symbols; + /* The suffix to append to the name of the real (claimed) object file when generating a dummy BFD to hold the IR symbols sent from the plugin. */ @@ -463,7 +466,7 @@ get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms) if (!blhe) { syms[n].resolution =3D LDPR_UNKNOWN; - continue; + goto report_symbol; } /* Determine resolution from blhe type and symbol's original type. = */ @@ -471,7 +474,7 @@ get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms) || blhe->type =3D=3D bfd_link_hash_undefweak) { syms[n].resolution =3D LDPR_UNDEF; - continue; + goto report_symbol; } if (blhe->type !=3D bfd_link_hash_defined && blhe->type !=3D bfd_link_hash_defweak @@ -516,7 +519,7 @@ get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms) syms[n].resolution =3D LDPR_RESOLVED_DYN; else syms[n].resolution =3D LDPR_RESOLVED_EXEC; - continue; + goto report_symbol; } /* Was originally def, or weakdef. Does it prevail? If the @@ -529,13 +532,18 @@ get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms) syms[n].resolution =3D (ironly ? LDPR_PREVAILING_DEF_IRONLY : LDPR_PREVAILING_DEF); - continue; + goto report_symbol; } /* Was originally def, weakdef, or common, but has been pre-empted. = */ - syms[n].resolution =3D is_ir_dummy_bfd (owner_sec->owner) - ? LDPR_PREEMPTED_IR - : LDPR_PREEMPTED_REG; + syms[n].resolution =3D (is_ir_dummy_bfd (owner_sec->owner) + ? LDPR_PREEMPTED_IR + : LDPR_PREEMPTED_REG); + +report_symbol: + if (report_plugin_symbols) + einfo ("%P: %B: symbol `%s' definition: %d, resolution: %d\n", + abfd, syms[n].name, syms[n].def, syms[n].resolution); } return LDPS_OK; } diff --git a/ld/plugin.h b/ld/plugin.h index 5b340be..6ba8fa8 100644 --- a/ld/plugin.h +++ b/ld/plugin.h @@ -21,6 +21,8 @@ #ifndef GLD_PLUGIN_H #define GLD_PLUGIN_H +/* Report plugin symbols. */ +extern bfd_boolean report_plugin_symbols; /* This is the only forward declaration we need to avoid having to include the plugin-api.h header in order to use this file. *