This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
RE: [Patch, LD]Fix GDB crash caused by discarding the grouped debug sections
- From: "Terry Guo" <terry dot guo at arm dot com>
- To: "'Alan Modra'" <amodra at gmail dot com>
- Cc: <binutils at sourceware dot org>
- Date: Mon, 8 Dec 2014 14:49:44 +0800
- Subject: RE: [Patch, LD]Fix GDB crash caused by discarding the grouped debug sections
- Authentication-results: sourceware.org; auth=none
- References: <000001d01299$98ff5170$cafdf450$ at arm dot com> <20141208062856 dot GA31968 at bubble dot grove dot modra dot org>
> -----Original Message-----
> From: Alan Modra [mailto:amodra@gmail.com]
> Sent: Monday, December 08, 2014 2:29 PM
> To: Terry Guo
> Cc: binutils@sourceware.org
> Subject: Re: [Patch, LD]Fix GDB crash caused by discarding the grouped
> debug sections
>
> On Mon, Dec 08, 2014 at 11:46:47AM +0800, Terry Guo wrote:
> > --- a/bfd/elflink.c
> > +++ b/bfd/elflink.c
> > @@ -11982,13 +11982,19 @@ _bfd_elf_gc_mark_extra_sections (struct
> bfd_link_info *info,
> > if (!some_kept)
> > continue;
> >
> > - /* Keep debug and special sections like .comment when they are
> > - not part of a group, or when we have single-member groups. */
> > + /* Keep special sections like .comment when they are not part of
> > + a group, or when we have single-member groups.
> > + Keep all kinds of debug sections. Debug section could exist
> > + as an individual section or a member of a section group.
> > + It is also possible that we have relocations from one debug
> > + section to another debug section. Selective elimination of
> > + debug section can cause incorrect resolution of relocations
> > + and break tools like gdb that consume them. */
> > for (isec = ibfd->sections; isec != NULL; isec = isec->next)
> > - if ((elf_next_in_group (isec) == NULL
> > - || elf_next_in_group (isec) == isec)
> > - && ((isec->flags & SEC_DEBUGGING) != 0
> > - || (isec->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) ==
> 0))
> > + if ((isec->flags & SEC_DEBUGGING) != 0
> > + || ((elf_next_in_group (isec) == NULL
> > + || elf_next_in_group (isec) == isec)
> > + && (isec->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) ==
> 0))
> > isec->gc_mark = 1;
> >
> > if (! debug_frag_seen)
>
> No, this breaks the rules for linking section groups. All sections of
> a group must either be included or omitted. See the ELF gABI.
>
> --
> Alan Modra
> Australia Development Lab, IBM
Thanks for comments. Then is it a proper solution if I update the patch to
keep other sections in same group?
BR,
Terry