This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]