Issues on Sframe on LoongArch with Link Time Relexation

Xi Ruoyao xry111@xry111.site
Thu Sep 25 08:41:27 GMT 2025


On Wed, 2025-09-24 at 15:20 -0700, Indu Bhagat via Binutils wrote:
> On 9/21/25 8:01 AM, Indu Bhagat wrote:
> > > > 
> > > > > -mno-relax(and -mthin-add-sub) in LoongArch gas can work around two
> > > > > issues, but any advice if not?
> > > > > 
> > > 
> > 
> > Ideally I would not go the route of not being able to support ld 
> > relaxations together with SFrame.  (I am traveling abit this week, will 
> > get back to you soon).
> > 
> > Meanwhile, what about the issue above related to reflecting change in PC 
> > offsets in SFrame FRE start addr when insns are edited.
> 
> Hi Huang,
> 
> When linker relaxations are enabled, updates to some debug sections, 
> .sframe, (and well, .eh_frame, .gcc_except_table too) are necessary.
> 
> Looks like linker relaxations on Loongarch are not well supported in 
> terms of updates to these metadata sections ( also ld -r will have 
> issues I think ?) in presence of linker relaxations.
> 
> IOW, there looks like a larger issue with linker relaxations on 
> Loongarch. Looking into ways to resolve the issues for SFrame, will 
> still not be enough for users.  Relocatable links are important for some 
> kernel usecases. Some consumers may want to perform symbolization after 
> getting stacktraces using SFrame, so updating other metadata when 
> performing linker relaxations is somewhat important too.
> 
> Can you share whats the plan around these issues ? We can surely move in 
> steps, but I would like to understand the long term plan with linker 
> relaxations on Loongarch.

With -mrelax, gas emits R_LARCH_32_PCREL and R_LARCH_{ADD,SUB}*
relocations for the entries in .eh_frame and .gcc_except_table which may
subject to change during relaxation.  These relocs are only resolved
after the relaxation.

Basically each metadata entry of which the value is a distance between
two addresses need to be coded with those relocs.

Relocatable linking a .o file assembled with -mno-relax and another
assembled with -mrelax together is indeed broken as at now.  AFAIK
Qinggang is trying to fix it.

-- 
Xi Ruoyao <xry111@xry111.site>


More information about the Binutils mailing list