From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17822 invoked by alias); 4 Apr 2006 07:57:10 -0000 Received: (qmail 17813 invoked by uid 22791); 4 Apr 2006 07:57:09 -0000 X-Spam-Check-By: sourceware.org Received: from province.act-europe.fr (HELO province.act-europe.fr) (212.157.227.214) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 04 Apr 2006 07:57:08 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-province.act-europe.fr (Postfix) with ESMTP id B6C924ACE8; Tue, 4 Apr 2006 09:57:04 +0200 (CEST) Received: from province.act-europe.fr ([127.0.0.1]) by localhost (province.act-europe.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 59849-04; Tue, 4 Apr 2006 09:57:04 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by province.act-europe.fr (Postfix) with ESMTP id 1896C4ACD1; Tue, 4 Apr 2006 09:57:04 +0200 (CEST) From: Eric Botcazou To: Alan Modra Subject: Re: [PATCH] New option --print-gc-sections Date: Tue, 04 Apr 2006 07:57:00 -0000 User-Agent: KMail/1.7.1 Cc: binutils@gcc.gnu.org, Arnaud Charlet References: <200603281131.41402.ebotcazou@adacore.com> <200604030839.41118.ebotcazou@adacore.com> <20060403075017.GB9418@bubble.grove.modra.org> In-Reply-To: <20060403075017.GB9418@bubble.grove.modra.org> MIME-Version: 1.0 Message-Id: <200604041000.55236.ebotcazou@adacore.com> Content-Type: Multipart/Mixed; boundary="Boundary-00=_3eiMEFLd+rWMT6a" Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2006-04/txt/msg00029.txt.bz2 --Boundary-00=_3eiMEFLd+rWMT6a Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 760 > I still like the idea of displaying discarded sections in the link map > output though. I think it would be useful to do so whenever -Map or -M > is given, so you wouldn't need a new ld option. You also shouldn't need > any new hooks. At the end of lang_map, just iterate over input > sections, looking for any that don't make it to the output bfd. Thanks, works fine. I've put it between the list of archives members included in the link and the memory map. Tested on AMD64/Linux. 2006-04-04 Eric Botcazou * ldlang.c (lang_map): Print the list of discarded input sections. (print_input_section): Change parameter and print zero-sized sections. (print_statement): Adjust call to print_input_section. -- Eric Botcazou --Boundary-00=_3eiMEFLd+rWMT6a Content-Type: text/x-diff; charset="iso-8859-1"; name="f115-010-2_217.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="f115-010-2_217.diff" Content-length: 2795 Index: ldlang.c =================================================================== RCS file: /cvs/src/src/ld/ldlang.c,v retrieving revision 1.213 diff -u -p -r1.213 ldlang.c --- ldlang.c 16 Mar 2006 12:20:16 -0000 1.213 +++ ldlang.c 4 Apr 2006 07:43:58 -0000 @@ -81,6 +81,7 @@ static void print_statement (lang_statem static void print_statement_list (lang_statement_union_type *, lang_output_section_statement_type *); static void print_statements (void); +static void print_input_section (asection *); static bfd_boolean lang_one_common (struct bfd_link_hash_entry *, void *); static void lang_record_phdrs (void); static void lang_do_version_exports_section (void); @@ -1598,6 +1599,22 @@ lang_map (void) lang_memory_region_type *m; bfd *p; + fprintf (config.map_file, _("\nDiscarded input sections\n\n")); + + LANG_FOR_EACH_INPUT_STATEMENT (file) + { + asection *s; + + if ((file->the_bfd->flags & (BFD_LINKER_CREATED | DYNAMIC)) != 0 + || file->just_syms_flag) + continue; + + for (s = file->the_bfd->sections; s != NULL; s = s->next) + if (s->output_section == NULL + || s->output_section->owner != output_bfd) + print_input_section (s); + } + minfo (_("\nMemory Configuration\n\n")); fprintf (config.map_file, "%-16s %-18s %-18s %s\n", _("Name"), _("Origin"), _("Length"), _("Attributes")); @@ -3475,13 +3492,12 @@ print_all_symbols (sec) /* Print information about an input section to the map file. */ static void -print_input_section (lang_input_section_type *in) +print_input_section (asection *i) { - asection *i = in->section; bfd_size_type size = i->size; init_opb (); - if (size != 0) + { int len; bfd_vma addr; @@ -3501,7 +3517,7 @@ print_input_section (lang_input_section_ ++len; } - if (i->output_section != NULL && (i->flags & SEC_EXCLUDE) == 0) + if (i->output_section != NULL && i->output_section->owner == output_bfd) addr = i->output_section->vma + i->output_offset; else { @@ -3528,7 +3544,7 @@ print_input_section (lang_input_section_ minfo (_("%W (size before relaxing)\n"), i->rawsize); } - if (i->output_section != NULL && (i->flags & SEC_EXCLUDE) == 0) + if (i->output_section != NULL && i->output_section->owner == output_bfd) { if (command_line.reduce_memory_overheads) bfd_link_hash_traverse (link_info.hash, print_one_symbol, i); @@ -3797,7 +3813,7 @@ print_statement (lang_statement_union_ty print_reloc_statement (&s->reloc_statement); break; case lang_input_section_enum: - print_input_section (&s->input_section); + print_input_section (s->input_section.section); break; case lang_padding_statement_enum: print_padding_statement (&s->padding_statement); --Boundary-00=_3eiMEFLd+rWMT6a--