[PATCH] x86: Check invalid TLS descriptor call

H.J. Lu hjl.tools@gmail.com
Tue Sep 3 02:41:24 GMT 2024


On Mon, Sep 2, 2024 at 10:53 AM Alexandre Oliva <oliva@gnu.org> wrote:
>
> On Aug 31, 2024, "H.J. Lu" <hjl.tools@gmail.com> wrote:
>
> > On Sat, Aug 31, 2024 at 4:07 AM Alexandre Oliva <oliva@gnu.org> wrote:
> >>
> >> On Aug 29, 2024, "H.J. Lu" <hjl.tools@gmail.com> wrote:
> >>
> >> > TLS descriptor call,
> >> > call *x@tlsdesc(%rax)
> >>
> >> > or
> >>
> >> > call *x@tlsdesc(%eax)
> >>
> >> > calls _dl_tlsdesc_return which expects that RAX/EAX points to the TLS
> >> > descriptor.
>
> >> But it doesn't follow that one must not use any other register that
> >> holds a copy of %[er]ax for the call, does it?
>
> > Did you mean that
>
> > lea foo@tlsdesc(%ebx), %eax
> > mov %eax, %ecx
> > call *foo@tlscall(%ecx)
>
> > also works?
>
> I didn't quite mean that; I meant there's no reason why it couldn't be
> made to work.
>

Of course, many different code sequences can work.  Since RAX/EAX
is the pointer to the TLS descriptor, why isn't it used?  Besides linker
issues an error if RAX/EAX isn't used when there is a TLS transition.


-- 
H.J.


More information about the Binutils mailing list