From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26168 invoked by alias); 22 Oct 2010 06:10:56 -0000 Received: (qmail 26145 invoked by uid 22791); 22 Oct 2010 06:10:50 -0000 X-SWARE-Spam-Status: No, hits=0.4 required=5.0 tests=AWL,BAYES_50,KAM_STOCKGEN,TW_FN,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 22 Oct 2010 06:10:42 +0000 Received: (qmail 29239 invoked from network); 22 Oct 2010 06:10:40 -0000 Received: from unknown (HELO ?192.168.0.105?) (mitchell@127.0.0.2) by mail.codesourcery.com with ESMTPA; 22 Oct 2010 06:10:40 -0000 Message-ID: <4CC12AE7.3010802@codesourcery.com> Date: Fri, 22 Oct 2010 06:10:00 -0000 From: Mark Mitchell User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.9) Gecko/20100915 Thunderbird/3.1.4 MIME-Version: 1.0 To: Ian Lance Taylor , binutils@sourceware.org Subject: Re: RFC: COMDAT group names become anonymouse local symbols References: <4CBFC470.5060202@codesourcery.com> <20101021062426.GU26553@bubble.grove.modra.org> <4CC06D28.5070900@codesourcery.com> <20101021185044.GA19120@caradoc.them.org> <4CC0A0E7.9090803@codesourcery.com> <20101021221944.GX26553@bubble.grove.modra.org> <4CC0C1AF.4050100@codesourcery.com> <20101021231110.GY26553@bubble.grove.modra.org> <4CC103C0.8010801@codesourcery.com> <20101022043313.GD26553@bubble.grove.modra.org> In-Reply-To: <20101022043313.GD26553@bubble.grove.modra.org> Content-Type: multipart/mixed; boundary="------------030809090003030906000202" 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: 2010-10/txt/msg00365.txt.bz2 This is a multi-part message in MIME format. --------------030809090003030906000202 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 621 On 10/21/2010 9:33 PM, Alan Modra wrote: > Create symbol after this point, so that now_seg and frag_now are in > the group section. It doesn't really matter which section you use for > the symbol, but the way you have it you'll get some random section. > In fact, you may as well move the sym check and create to.. > >> ! elf_group_id (s) = sy->bsym; > > ..just before here. Which reminds me, use symbol_get_bfdsym here > since we are before set_symtab. How about this version? Thanks for for helping me to work through this problem. -- Mark Mitchell CodeSourcery mark@codesourcery.com (650) 331-3385 x713 --------------030809090003030906000202 Content-Type: text/plain; name="gas.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gas.patch" Content-length: 14732 2010-10-21 Mark Mitchell * config/obj-elf.c (elf_adjust_symtab): New. Move group section processing here from elf_frob_file. Ensure that group signature symbols have the name of the group. (elf_frob_file): Move group section processing to elf_adjust_symtab. * config/obj-elf.h (elf_adjust_symtab): Declare. (obj_adjust_symtab): Define. 2010-10-21 Mark Mitchell * gas/elf/elf.exp: Add group0c test. * gas/elf/group0c.d: New. * gas/elf/group0a.d: Expect ".group" for the name of group sections. * gas/elf/group0b.d: Likewise. * gas/elf/group1a.d: Likewise. * gas/elf/group1b.d: Likewise. * gas/elf/groupautoa.d: Likewise. * gas/elf/groupautob.d: Likewise. * gas/elf/section4.d: Likewise. 2010-10-18 Kai Tietz Index: gas/config/obj-elf.c =================================================================== RCS file: /cvs/src/src/gas/config/obj-elf.c,v retrieving revision 1.131 diff -c -5 -p -r1.131 obj-elf.c *** gas/config/obj-elf.c 16 Sep 2010 23:55:09 -0000 1.131 --- gas/config/obj-elf.c 22 Oct 2010 06:06:43 -0000 *************** static void free_section_idx (const char *** 2079,2114 **** { free ((unsigned int *) val); } void ! elf_frob_file (void) { struct group_list list; unsigned int i; - bfd_map_over_sections (stdoutput, adjust_stab_sections, NULL); - /* Go find section groups. */ list.num_group = 0; list.head = NULL; list.elt_count = NULL; ! list.indexes = hash_new (); bfd_map_over_sections (stdoutput, build_group_lists, &list); ! /* Make the SHT_GROUP sections that describe each section group. We can't set up the section contents here yet, because elf section indices have yet to be calculated. elf.c:set_group_contents does the rest of the work. */ ! for (i = 0; i < list.num_group; i++) { const char *group_name = elf_group_name (list.head[i]); const char *sec_name; asection *s; flagword flags; struct symbol *sy; - int has_sym; bfd_size_type size; flags = SEC_READONLY | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_GROUP; for (s = list.head[i]; s != NULL; s = elf_next_in_group (s)) if ((s->flags ^ flags) & SEC_LINK_ONCE) --- 2079,2111 ---- { free ((unsigned int *) val); } void ! elf_adjust_symtab (void) { struct group_list list; unsigned int i; /* Go find section groups. */ list.num_group = 0; list.head = NULL; list.elt_count = NULL; ! list.indexes = hash_new (); bfd_map_over_sections (stdoutput, build_group_lists, &list); ! /* Make the SHT_GROUP sections that describe each section group. We can't set up the section contents here yet, because elf section indices have yet to be calculated. elf.c:set_group_contents does the rest of the work. */ ! for (i = 0; i < list.num_group; i++) { const char *group_name = elf_group_name (list.head[i]); const char *sec_name; asection *s; flagword flags; struct symbol *sy; bfd_size_type size; flags = SEC_READONLY | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_GROUP; for (s = list.head[i]; s != NULL; s = elf_next_in_group (s)) if ((s->flags ^ flags) & SEC_LINK_ONCE) *************** elf_frob_file (void) *** 2120,2140 **** group_name); break; } } ! sec_name = group_name; ! sy = symbol_find_exact (group_name); ! has_sym = 0; ! if (sy != NULL ! && (sy == symbol_lastP ! || (sy->sy_next != NULL ! && sy->sy_next->sy_previous == sy))) ! { ! has_sym = 1; ! sec_name = ".group"; ! } s = subseg_force_new (sec_name, 0); if (s == NULL || !bfd_set_section_flags (stdoutput, s, flags) || !bfd_set_section_alignment (stdoutput, s, 2)) { --- 2117,2127 ---- group_name); break; } } ! sec_name = ".group"; s = subseg_force_new (sec_name, 0); if (s == NULL || !bfd_set_section_flags (stdoutput, s, flags) || !bfd_set_section_alignment (stdoutput, s, 2)) { *************** elf_frob_file (void) *** 2143,2171 **** } elf_section_type (s) = SHT_GROUP; /* Pass a pointer to the first section in this group. */ elf_next_in_group (s) = list.head[i]; ! if (has_sym) ! elf_group_id (s) = sy->bsym; size = 4 * (list.elt_count[i] + 1); bfd_set_section_size (stdoutput, s, size); s->contents = (unsigned char *) frag_more (size); frag_now->fr_fix = frag_now_fix_octets (); frag_wane (frag_now); } - #ifdef elf_tc_final_processing - elf_tc_final_processing (); - #endif - /* Cleanup hash. */ hash_traverse (list.indexes, free_section_idx); hash_die (list.indexes); } /* It removes any unneeded versioned symbols from the symbol table. */ void elf_frob_file_before_adjust (void) { --- 2130,2176 ---- } elf_section_type (s) = SHT_GROUP; /* Pass a pointer to the first section in this group. */ elf_next_in_group (s) = list.head[i]; ! /* Make sure that the signature symbol for the group has the ! name of the group. */ ! sy = symbol_find_exact (group_name); ! if (!sy ! || (sy != symbol_lastP ! && (sy->sy_next == NULL ! || sy->sy_next->sy_previous != sy))) ! { ! /* Create the symbol now. */ ! sy = symbol_new (group_name, now_seg, (valueT) 0, frag_now); ! symbol_get_obj (sy)->local = 1; ! symbol_table_insert (sy); ! } ! elf_group_id (s) = symbol_get_bfdsym (sy); size = 4 * (list.elt_count[i] + 1); bfd_set_section_size (stdoutput, s, size); s->contents = (unsigned char *) frag_more (size); frag_now->fr_fix = frag_now_fix_octets (); frag_wane (frag_now); } /* Cleanup hash. */ hash_traverse (list.indexes, free_section_idx); hash_die (list.indexes); } + void + elf_frob_file (void) + { + bfd_map_over_sections (stdoutput, adjust_stab_sections, NULL); + + #ifdef elf_tc_final_processing + elf_tc_final_processing (); + #endif + } + /* It removes any unneeded versioned symbols from the symbol table. */ void elf_frob_file_before_adjust (void) { Index: gas/config/obj-elf.h =================================================================== RCS file: /cvs/src/src/gas/config/obj-elf.h,v retrieving revision 1.37 diff -c -5 -p -r1.37 obj-elf.h *** gas/config/obj-elf.h 13 Jan 2010 14:08:52 -0000 1.37 --- gas/config/obj-elf.h 22 Oct 2010 06:06:43 -0000 *************** void elf_copy_symbol_attributes (symbolS *** 195,204 **** --- 195,209 ---- #ifndef OBJ_COPY_SYMBOL_ATTRIBUTES #define OBJ_COPY_SYMBOL_ATTRIBUTES(DEST, SRC) \ (elf_copy_symbol_attributes (DEST, SRC)) #endif + void elf_adjust_symtab (void); + #ifndef obj_adjust_symtab + #define obj_adjust_symtab elf_adjust_symtab + #endif + #ifndef SEPARATE_STAB_SECTIONS /* Avoid ifndef each separate macro setting by wrapping the whole of the stab group on the assumption that whoever sets SEPARATE_STAB_SECTIONS caters to ECOFF_DEBUGGING and the right setting of INIT_STAB_SECTIONS and OBJ_PROCESS_STAB too, without needing the tweaks below. */ Index: gas/testsuite/gas/elf/elf.exp =================================================================== RCS file: /cvs/src/src/gas/testsuite/gas/elf/elf.exp,v retrieving revision 1.67 diff -c -5 -p -r1.67 elf.exp *** gas/testsuite/gas/elf/elf.exp 20 Sep 2010 16:07:27 -0000 1.67 --- gas/testsuite/gas/elf/elf.exp 22 Oct 2010 06:06:43 -0000 *************** if { ([istarget "*-*-*elf*"] *** 102,111 **** --- 102,112 ---- run_dump_test "file" } } run_dump_test "group0a" run_dump_test "group0b" + run_dump_test "group0c" run_dump_test "group1a" run_dump_test "group1b" run_dump_test "groupautoa" run_dump_test "groupautob" case $target_triplet in { Index: gas/testsuite/gas/elf/group0a.d =================================================================== RCS file: /cvs/src/src/gas/testsuite/gas/elf/group0a.d,v retrieving revision 1.2 diff -c -5 -p -r1.2 group0a.d *** gas/testsuite/gas/elf/group0a.d 25 Nov 2004 00:56:00 -0000 1.2 --- gas/testsuite/gas/elf/group0a.d 22 Oct 2010 06:06:43 -0000 *************** *** 1,10 **** #readelf: -SW #name: group section #source: group0.s #... ! [ ]*\[.*\][ ]+\.foo_group[ ]+GROUP.* #... [ ]*\[.*\][ ]+\.foo[ ]+PROGBITS.*[ ]+AXG[ ]+.* [ ]*\[.*\][ ]+\.bar[ ]+PROGBITS.*[ ]+AG[ ]+.* #pass --- 1,10 ---- #readelf: -SW #name: group section #source: group0.s #... ! [ ]*\[.*\][ ]+\.group[ ]+GROUP.* #... [ ]*\[.*\][ ]+\.foo[ ]+PROGBITS.*[ ]+AXG[ ]+.* [ ]*\[.*\][ ]+\.bar[ ]+PROGBITS.*[ ]+AG[ ]+.* #pass Index: gas/testsuite/gas/elf/group0b.d =================================================================== RCS file: /cvs/src/src/gas/testsuite/gas/elf/group0b.d,v retrieving revision 1.2 diff -c -5 -p -r1.2 group0b.d *** gas/testsuite/gas/elf/group0b.d 25 May 2005 06:30:25 -0000 1.2 --- gas/testsuite/gas/elf/group0b.d 22 Oct 2010 06:06:43 -0000 *************** *** 1,10 **** #readelf: -g #name: group section #source: group0.s #... ! COMDAT group section \[ 1\] `.foo_group' \[.foo_group\] contains 2 sections: [ ]+\[Index\][ ]+Name [ ]+\[.*\][ ]+.foo [ ]+\[.*\][ ]+.bar #pass --- 1,10 ---- #readelf: -g #name: group section #source: group0.s #... ! COMDAT group section \[ 1\] `\.group' \[.foo_group\] contains 2 sections: [ ]+\[Index\][ ]+Name [ ]+\[.*\][ ]+.foo [ ]+\[.*\][ ]+.bar #pass Index: gas/testsuite/gas/elf/group0c.d =================================================================== RCS file: gas/testsuite/gas/elf/group0c.d diff -N gas/testsuite/gas/elf/group0c.d *** /dev/null 1 Jan 1970 00:00:00 -0000 --- gas/testsuite/gas/elf/group0c.d 22 Oct 2010 06:06:43 -0000 *************** *** 0 **** --- 1,7 ---- + #readelf: -sW + #name: group section name + #source: group0.s + + #... + .*NOTYPE[ ]+LOCAL[ ]+DEFAULT[ ]+[0-9]+[ ]+\.foo_group + #pass Index: gas/testsuite/gas/elf/group1a.d =================================================================== RCS file: /cvs/src/src/gas/testsuite/gas/elf/group1a.d,v retrieving revision 1.2 diff -c -5 -p -r1.2 group1a.d *** gas/testsuite/gas/elf/group1a.d 25 Nov 2004 00:56:00 -0000 1.2 --- gas/testsuite/gas/elf/group1a.d 22 Oct 2010 06:06:43 -0000 *************** *** 1,11 **** #readelf: -SW #name: group section with multiple sections of same name #source: group1.s #... ! [ ]*\[.*\][ ]+\.foo_group[ ]+GROUP.* #... [ ]*\[.*\][ ]+\.text[ ]+PROGBITS.*[ ]+AX[ ]+.* #... [ ]*\[.*\][ ]+\.text[ ]+PROGBITS.*[ ]+AXG[ ]+.* #pass --- 1,11 ---- #readelf: -SW #name: group section with multiple sections of same name #source: group1.s #... ! [ ]*\[.*\][ ]+\.group[ ]+GROUP.* #... [ ]*\[.*\][ ]+\.text[ ]+PROGBITS.*[ ]+AX[ ]+.* #... [ ]*\[.*\][ ]+\.text[ ]+PROGBITS.*[ ]+AXG[ ]+.* #pass Index: gas/testsuite/gas/elf/group1b.d =================================================================== RCS file: /cvs/src/src/gas/testsuite/gas/elf/group1b.d,v retrieving revision 1.2 diff -c -5 -p -r1.2 group1b.d *** gas/testsuite/gas/elf/group1b.d 25 May 2005 06:30:25 -0000 1.2 --- gas/testsuite/gas/elf/group1b.d 22 Oct 2010 06:06:43 -0000 *************** *** 1,9 **** #readelf: -g #name: group section with multiple sections of same name #source: group1.s #... ! COMDAT group section \[ 1\] `.foo_group' \[.foo_group\] contains 1 sections: [ ]+\[Index\][ ]+Name [ ]+\[.*\][ ]+.text #pass --- 1,9 ---- #readelf: -g #name: group section with multiple sections of same name #source: group1.s #... ! COMDAT group section \[ 1\] `\.group' \[.foo_group\] contains 1 sections: [ ]+\[Index\][ ]+Name [ ]+\[.*\][ ]+.text #pass Index: gas/testsuite/gas/elf/groupautoa.d =================================================================== RCS file: /cvs/src/src/gas/testsuite/gas/elf/groupautoa.d,v retrieving revision 1.1 diff -c -5 -p -r1.1 groupautoa.d *** gas/testsuite/gas/elf/groupautoa.d 18 Aug 2010 00:43:46 -0000 1.1 --- gas/testsuite/gas/elf/groupautoa.d 22 Oct 2010 06:06:43 -0000 *************** *** 1,11 **** #readelf: -SW #name: automatic section group #source: groupauto.s #... ! [ ]*\[.*\][ ]+some_group[ ]+GROUP.* #... [ ]*\[.*\][ ]+\.text[ ]+PROGBITS.*[ ]+AX[ ]+.* #... [ ]*\[.*\][ ]+\.foo[ ]+PROGBITS.*[ ]+A[ ]+.* #... --- 1,11 ---- #readelf: -SW #name: automatic section group #source: groupauto.s #... ! [ ]*\[.*\][ ]+\.group[ ]+GROUP.* #... [ ]*\[.*\][ ]+\.text[ ]+PROGBITS.*[ ]+AX[ ]+.* #... [ ]*\[.*\][ ]+\.foo[ ]+PROGBITS.*[ ]+A[ ]+.* #... Index: gas/testsuite/gas/elf/groupautob.d =================================================================== RCS file: /cvs/src/src/gas/testsuite/gas/elf/groupautob.d,v retrieving revision 1.1 diff -c -5 -p -r1.1 groupautob.d *** gas/testsuite/gas/elf/groupautob.d 18 Aug 2010 00:43:46 -0000 1.1 --- gas/testsuite/gas/elf/groupautob.d 22 Oct 2010 06:06:43 -0000 *************** *** 1,10 **** #readelf: -g #name: automatic section group #source: groupauto.s #... ! COMDAT group section \[ 1\] `some_group' \[some_group\] contains 2 sections: [ ]+\[Index\][ ]+Name [ ]+\[.*\][ ]+.text [ ]+\[.*\][ ]+.note.bar #pass --- 1,10 ---- #readelf: -g #name: automatic section group #source: groupauto.s #... ! COMDAT group section \[ 1\] `\.group' \[some_group\] contains 2 sections: [ ]+\[Index\][ ]+Name [ ]+\[.*\][ ]+.text [ ]+\[.*\][ ]+.note.bar #pass Index: gas/testsuite/gas/elf/section4.d =================================================================== RCS file: /cvs/src/src/gas/testsuite/gas/elf/section4.d,v retrieving revision 1.2 diff -c -5 -p -r1.2 section4.d *** gas/testsuite/gas/elf/section4.d 25 Nov 2004 00:56:00 -0000 1.2 --- gas/testsuite/gas/elf/section4.d 22 Oct 2010 06:06:43 -0000 *************** *** 1,10 **** #readelf: --sections #name: label arithmetic with multiple same-name sections #... ! [ ]*\[.*\][ ]+foo[ ]+GROUP.* #... [ ]*\[.*\][ ]+\.text[ ]+PROGBITS.* #... [ ]*\[.*\][ ]+\.data[ ]+PROGBITS.* #... --- 1,10 ---- #readelf: --sections #name: label arithmetic with multiple same-name sections #... ! [ ]*\[.*\][ ]+\.group[ ]+GROUP.* #... [ ]*\[.*\][ ]+\.text[ ]+PROGBITS.* #... [ ]*\[.*\][ ]+\.data[ ]+PROGBITS.* #... popd --------------030809090003030906000202--