This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] Issue a linker error if TLS sections are not adjacent
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Binutils <binutils at sourceware dot org>
- Date: Thu, 23 Jan 2014 08:17:42 -0800
- Subject: Re: [PATCH] Issue a linker error if TLS sections are not adjacent
- Authentication-results: sourceware.org; auth=none
- References: <20140122193013 dot GA4156 at intel dot com> <20140123035510 dot GZ5390 at bubble dot grove dot modra dot org> <CAMe9rOq6KvUnsrzQTEBE9XzHM8DKC4UaWqLet_NgReVE0kCT-A at mail dot gmail dot com>
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.