From: Mark Mitchell <mark@codesourcery.com>
To: Ian Lance Taylor <iant@google.com>, binutils@sourceware.org
Subject: Re: RFC: COMDAT group names become anonymouse local symbols
Date: Fri, 22 Oct 2010 06:10:00 -0000 [thread overview]
Message-ID: <4CC12AE7.3010802@codesourcery.com> (raw)
In-Reply-To: <20101022043313.GD26553@bubble.grove.modra.org>
[-- Attachment #1: Type: text/plain, Size: 621 bytes --]
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
[-- Attachment #2: gas.patch --]
[-- Type: text/plain, Size: 14732 bytes --]
2010-10-21 Mark Mitchell <mark@codesourcery.com>
* 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 <mark@codesourcery.com>
* 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 <kaI.tietz@onevision.com>
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
next prev parent reply other threads:[~2010-10-22 6:10 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-19 20:08 Mark Mitchell
2010-10-20 18:05 ` Cary Coutant
2010-10-20 18:19 ` Mark Mitchell
2010-10-21 6:12 ` Cary Coutant
2010-10-21 0:18 ` Alan Modra
2010-10-21 0:31 ` Mark Mitchell
2010-10-21 1:04 ` Ian Lance Taylor
2010-10-21 4:41 ` Mark Mitchell
2010-10-21 5:19 ` H.J. Lu
2010-10-21 5:27 ` Mark Mitchell
2010-10-21 5:41 ` H.J. Lu
2010-10-21 5:42 ` Mark Mitchell
2010-10-21 6:24 ` Alan Modra
2010-10-21 16:41 ` Mark Mitchell
2010-10-21 18:50 ` Daniel Jacobowitz
2010-10-21 20:22 ` Mark Mitchell
2010-10-21 22:19 ` Alan Modra
2010-10-21 22:41 ` Mark Mitchell
2010-10-21 23:11 ` Alan Modra
2010-10-22 3:23 ` Mark Mitchell
2010-10-22 4:33 ` Alan Modra
2010-10-22 6:10 ` Mark Mitchell [this message]
2010-10-22 7:16 ` Alan Modra
2010-10-22 15:34 ` Mark Mitchell
2010-10-23 8:16 ` Alan Modra
2010-10-23 18:05 ` Mark Mitchell
2010-10-24 1:15 ` Hans-Peter Nilsson
2010-10-24 1:43 ` Mark Mitchell
2010-10-24 3:50 ` Hans-Peter Nilsson
2010-10-24 4:34 ` Mark Mitchell
2010-10-25 11:45 ` Hans-Peter Nilsson
2010-10-25 12:39 ` Alan Modra
2010-10-25 15:22 ` Mark Mitchell
2010-10-26 3:45 ` Alan Modra
2010-10-26 15:48 ` Dave Korn
2010-10-26 15:49 ` Mark Mitchell
2010-10-26 15:59 ` Dave Korn
2010-10-26 16:12 ` Dave Korn
2010-10-21 2:12 ` Alan Modra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4CC12AE7.3010802@codesourcery.com \
--to=mark@codesourcery.com \
--cc=binutils@sourceware.org \
--cc=iant@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).