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: Alan Modra <amodra at gmail dot com>
- To: Terry Guo <terry dot guo at arm dot com>
- Cc: binutils at sourceware dot org
- Date: Mon, 8 Dec 2014 16:58:56 +1030
- 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>
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