On Sat, 2024-01-27 at 11:15 +0800, chenglulu wrote:
> 
> 在 2024/1/26 下午6:57, Xi Ruoyao 写道:
> > On Fri, 2024-01-26 at 16:59 +0800, chenglulu wrote:
> > > 在 2024/1/26 下午4:49, Xi Ruoyao 写道:
> > > > On Fri, 2024-01-26 at 15:37 +0800, Lulu Cheng wrote:
> > > > > v3 -> v4:
> > > > >     1. Add macro support for TLS symbols
> > > > >     2. Added support for loading __get_tls_addr symbol address using 
> > > > > call36.
> > > > >     3. Merge template got_load_tls_{ld/gd/le/ie}.
> > > > >     4. Enable explicit reloc for extreme TLS GD/LD with 
> > > > > -mexplicit-relocs=auto.
> > > > I've rebased and attached the patch to fix the bad split in -mexplicit-
> > > > relocs={always,auto} -mcmodel=extreme on top of this series.  I've not
> > > > tested it seriously though (only tested the added and modified test
> > > > cases).
> > > > 
> > > OK, I'll test the spec for correctness.
> > I suppose this still won't work yet because Binutils is not fully fixed.
> > GAS has been changed not to emit R_LARCH_RELAX for "la.tls.ie a0, t0,
> > foo", but ld is still not checking if an R_LARCH_RELAX is after
> > R_LARCH_TLS_IE_PC_{HI20,LO12} properly.  Thus an invalid "partial" TLS
> > transition can still happen.
> > 
> 
> The following situations are not handled in the patch:
> 
> diff --git a/gcc/config/loongarch/loongarch.cc 
> b/gcc/config/loongarch/loongarch.cc
> 
> index 3fab4b64453..6336a9f696f 100644
> --- a/gcc/config/loongarch/loongarch.cc
> +++ b/gcc/config/loongarch/loongarch.cc
> @@ -7472,7 +7472,13 @@ loongarch_output_mi_thunk (FILE *file, tree 
> thunk_fndecl ATTRIBUTE_UNUSED,
>       {
>         if (TARGET_CMODEL_EXTREME)
>          {
> -         emit_insn (gen_movdi_symbolic_off64 (temp1, fnaddr, temp2));
> +         if (la_opt_explicit_relocs != EXPLICIT_RELOCS_NONE)
> +           {
> +             emit_insn (gen_la_pcrel64_two_parts (temp1, temp2, fnaddr));
> +             emit_move_insn (temp1, gen_rtx_PLUS (Pmode, temp1, temp2));
> +           }
> +         else
> +           emit_insn (gen_movdi_symbolic_off64 (temp1, fnaddr, temp2));
>            insn = emit_call_insn (gen_sibcall_internal (temp1, const0_rtx));
>          }
>         else
> @@ -7482,7 +7488,15 @@ loongarch_output_mi_thunk (FILE *file, tree 
> thunk_fndecl ATTRIBUTE_UNUSED,
>     else
>       {
>         if (TARGET_CMODEL_EXTREME)
> -       emit_insn (gen_movdi_symbolic_off64 (temp1, fnaddr, temp2));
> +       {
> +         if (la_opt_explicit_relocs != EXPLICIT_RELOCS_NONE)
> +           {
> +             emit_insn (gen_la_pcrel64_two_parts (temp1, temp2, fnaddr));
> +             emit_move_insn (temp1, gen_rtx_PLUS (Pmode, temp1, temp2));
> +           }
> +         else
> +           emit_insn (gen_movdi_symbolic_off64 (temp1, fnaddr, temp2));
> +       }
>         else
>          loongarch_emit_move (temp1, fnaddr);

In deed.  Considering the similarity of these two hunks I'll separate
the logic into a static function though.  And I'll also add some test
case for them...

-- 
Xi Ruoyao <xry...@xry111.site>
School of Aerospace Science and Technology, Xidian University

Reply via email to