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] Issue a linker error if TLS sections are not adjacent


On Wed, Jan 22, 2014 at 8:19 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Jan 22, 2014 at 7:55 PM, Alan Modra <amodra@gmail.com> wrote:
>> On Wed, Jan 22, 2014 at 11:30:13AM -0800, H.J. Lu wrote:
>>>       PR ld/16498
>>>       * elf.c (_bfd_elf_map_sections_to_segments): Issue a linker error
>>>       if TLS sections are not adjacent.
>>
>> This part is OK.
>
> I'd like to augment my patch like
>
> ---
> index 3815e32..c0303fc 100644
> --- a/bfd/elf.c
> +++ b/bfd/elf.c
> @@ -4117,11 +4117,31 @@ _bfd_elf_map_sections_to_segments (bfd *abfd,
> struct bfd_link_info *info)
>        /* Mandated PF_R.  */
>        m->p_flags = PF_R;
>        m->p_flags_valid = 1;
> +      s = first_tls;
>        for (i = 0; i < (unsigned int) tls_count; ++i)
>          {
> -          BFD_ASSERT (first_tls->flags & SEC_THREAD_LOCAL);
> -          m->sections[i] = first_tls;
> -          first_tls = first_tls->next;
> +          if ((s->flags & SEC_THREAD_LOCAL) == 0)
> +        {
> +          _bfd_error_handler
> +            (_("%B: TLS sections are not adjacent:"), abfd);
> +          s = first_tls;
> +          i = 0;
> +          while (i < (unsigned int) tls_count)
> +            {
> +              if ((s->flags & SEC_THREAD_LOCAL) != 0)
> +            {
> +              _bfd_error_handler (_("        TLS: %A"), s);
> +              i++;
> +            }
> +              else
> +            _bfd_error_handler (_("    non-TLS: %A"), s);
> +              s = s->next;
> +            }
> +          bfd_set_error (bfd_error_bad_value);
> +          goto error_return;
> +        }
> +          m->sections[i] = s;
> +          s = s->next;
>          }
>
>        *pm = m;
> ---
>
> So that user has a clue what went wrong.  This gives me:

I checked in this enhanced patch without the testcase.

Thanks.

-- 
H.J.


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