[PATCH v2] x86: Add tls check in gas
Cui, Lili
lili.cui@intel.com
Tue Sep 10 01:28:22 GMT 2024
> -----Original Message-----
> From: Cui, Lili <lili.cui@intel.com>
> Sent: Monday, September 9, 2024 4:16 PM
> To: H.J. Lu <hjl.tools@gmail.com>
> Cc: Beulich, Jan <JBeulich@suse.com>; binutils@sourceware.org
> Subject: RE: [PATCH v2] x86: Add tls check in gas
>
>
> > > if (i.has_gotrel && tls_check)
> > >
> > > > > > + {
> > > > > > + enum x86_tls_error_type tls_error;
> > > > > > + for (j = 0; j < i.operands; ++j)
> > > > > > + if ((tls_error = x86_check_tls_relocation
> > > > > > + (i.reloc[j])) !=
> > x86_tls_error_none)
> > > > > > + x86_report_tls_error (tls_error, i.reloc[j]);
> > >
> > > {
> > > tls_error = x86_check_tls_relocation (i.reloc[j]);
> > > if (tls_error == x86_tls_error_continue)
> > > continue;
> > >
> > > if (tls_error != x86_tls_error_none)
> > > x86_report_tls_error (tls_error, i.reloc[j]);
> > > break;
> > > }
> > >
> >
> > This patch is on top of your patch.
> >
>
> Applied this patch, thanks! Only one place that I think there is a bug.
>
> > > > + case BFD_RELOC_X86_64_TLSLD:
> > > > + /* Check transition from LD access model:
> > > > +
> > > > + leaq foo@tlsld(%rip), %rdi --> Only this fixed format is supported.
> > > > + */
> > > > + if (i.tm.mnem_off != MN_lea)
> > > > + return x86_tls_error_insn;
> > > > + else if (!i.base_reg)
> > > > + return x86_tls_error_no_base_reg;
> > > > + else if (i.base_reg->reg_num != RegIP)
> > > > + return x86_tls_error_RegIP;
> > > > + else if (i.types[1].bitfield.instance != RegDI)
> >
> > Use
> >
> > else if (i.types[1].bitfield.class != Reg
> > || !i.op[1].regs->reg_type.bitfield.qword
> > || i.op[1].regs->reg_num != EDI_REG_NUM)
> > return x86_tls_error_dest_RegDI;
> >
>
> If we use reg_num, the following illegal usage will also pass the test.
>
> leaq bar@tlsgd(%rip), %r15
>
Fixed , added "i.op[1].regs->reg_flags" check.
Thanks,
Lili.
More information about the Binutils
mailing list