On 8/18/2026 5:10 PM, [email protected] wrote:

> This commit adds x86-specific support for unwinding through GNU linker
> generated PLT entries by handling the CFA expression found in .eh_frame.
> It explicitly aims to enable this for both i386 and x86-64 binaries.
> 
>> diff --git a/arch/x86/include/asm/unwind_user_eh_frame.h 
>> b/arch/x86/include/asm/unwind_user_eh_frame.h
>> index fdccbda2fe4b1..8268eb1a0ff5a 100644
>> --- a/arch/x86/include/asm/unwind_user_eh_frame.h
>> +++ b/arch/x86/include/asm/unwind_user_eh_frame.h
> [ ... ]
>> +static inline int eh_frame_do_def_cfa_expression(const char *expr,
>> +                                             int size,
>> +                                             unsigned long ip,
>> +                                             struct eh_frame_reg_state 
>> *reg_state)
>> +{
> [ ... ]
>> +            sp_reg = DW_OP_breg_register(sp_op);
>> +            ip_reg = DW_OP_breg_register(ip_op);
>> +            if (sp_reg != EH_FRAME_REG_SP || ip_reg != EH_FRAME_REG_RA)
>> +                    return -EOPNOTSUPP;
> 
> [Severity: Medium]
> Does this unconditionally reject 32-bit i386 PLT expressions?
> 
> The commit message mentions enabling unwinding for both i386 and x86-64,
> and the comment above notes the 32-bit DWARF registers 4 (ESP) and 8 (EIP).
> However, this check requires the parsed DWARF register values to match
> EH_FRAME_REG_SP (7) and EH_FRAME_REG_RA (16), which are exclusively the
> x86-64 register mappings. 
> 
> Will this cause valid i386 expressions to fail and return -EOPNOTSUPP?
> 
> While 32-bit eh_frame unwinding is currently disabled at a higher level
> for x86-64 tasks, this logic appears to contradict the intended architectural
> support.

When enabling i386 support, one would define EH_FRAME_REG_SP and
EH_FRAME_REG_RA to the respective i386 constants.  The PLT expressions
used by the GNU linker are otherwise the same.

For 32-bit compat (and x32?) this is different.  This may require
the definitions to be changed to functions that dynamically return the
respective register constant values.

> 
>> +
>> +            /* CFA = (SP + SP_offset) + (((IP & 0xf) >= N) << shift) */
>> +            reg_state->cfa_rule = CFA_REG_OFFSET;
>> +            reg_state->cfa_regnum = EH_FRAME_REG_SP;
> 

Regards,
Jens
-- 
Jens Remus
Linux on Z Development (D3303)
[email protected] / [email protected]

IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: 
Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: 
Ehningen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/


Reply via email to