[2.43 PATCH] LoongArch: Fix broken DESC => IE transition for 2.43 branch

Icenowy Zheng uwu@icenowy.me
Thu Dec 19 10:46:00 GMT 2024


在 2024-12-19星期四的 17:18 +0800,Xi Ruoyao写道:
> On Thu, 2024-12-19 at 17:04 +0800, Icenowy Zheng wrote:
> > 在 2024-12-19星期四的 13:23 +0800,Xi Ruoyao写道:
> > > If code compiled with -fPIC -mtls-dialect=desc is linked into a
> > > PDE
> > > or
> > > PIE, and the code refers to external DSO symbols, we can produce
> > > broken
> > > link unit as check_relocs expects DESC => IE transition to happen
> > > and
> > > emits a TLS IE entry in the GOT, but a too early "continue" in
> > > relax_section actually jumps over the DESC => IE transition so
> > > the
> > > code
> > > sequence is unchanged and still expecting a TLS descriptor
> > > (instead
> > > of
> > > an IE entry) in the GOT.
> > > 
> > > The bug is already fixed in master branch by commit 5c3d09c1855b
> > > ("LoongArch: Optimize the relaxation process") so this fix is
> > > only
> > > needed for the 2.43 branch.
> > > 
> > > Reported-by: Icenowy Zheng <uwu@icenowy.me>
> > 
> > My original case (which is compiling a full-featured Mesa) fails in
> > another way after applying this patch -- originally it fails
> > because
> > intel_clc gets segfault (which uses std::call_once to initialize
> > LLVM),
> > now it fails when linking some .so files (including libgallium).
> > 
> > Here's the backtrace:
> > 
> > ```
> > #0  loongarch_can_trans_tls (input_bfd=<optimized out>,
> > info=0x555558f60b78 <link_info>, h=0x0, r_symndx=<optimized out>,
> > r_type=<optimized out>)
> >     at /var/cache/acbs/build/acbs._4a9gw_q/binutils-
> > 2.43.1/bfd/elfnn-
> > loongarch.c:787
> 
> I guess (not sure) it's fixed by
> 
> commit 28489a70d4660d67e71d75e82286a6e1a7003b93
> Author: Xin Wang <yw987194828@gmail.com>
> Date:   Fri Sep 6 09:00:12 2024 +0800
> 
>     LoongArch: Add elfNN_loongarch_mkobject to initialize LoongArch
> tdata
> 

Yes, picking this patch makes everything normal now.

So, for the original patch in the mail's subject,

Tested-By: Icenowy Zheng <uwu@icenowy.me>

Thanks!
Icenowy

> This is already backported to 2.43 branch as commit
> c40337b1784d81c615a5dd9fd391f6677e52c6d8.
> 



More information about the Binutils mailing list