[PATCH v3 1/1] bfd/loongarch: set PRSTATUS_SIZE=0x1e0 to match kernel's struct elf_prstatus size

Tiezhu Yang yangtiezhu@loongson.cn
Mon Nov 10 02:42:24 GMT 2025


Cc:
Chenghua Xu <xuchenghua@loongson.cn>
Zhensong Liu <liuzhensong@loongson.cn>

On 2025/11/5 下午2:24, lijian1@kylinos.cn wrote:
> From: lijian1 <lijian1@kylinos.cn>
> 
> The size of struct elf_prstatus in the Linux kernel for loongarch64
> is 0x1e0 (480 bytes, including padding).  The current PRSTATUS_SIZE
> value in BFD was 0x1d8, which causes inconsistency with the kernel
> definition and can not lead to the correct branch for loongarch64 backend.
> 
> This patch updates PRSTATUS_SIZE to 0x1e0 for loongarch64 to match
> the kernel's definition.
> 
> Tested with Linux kernel 6.6 and GDB 14.1; verified that core file
> sections (.reg, NT_PRSTATUS) are parsed in correct branch.

Please test with the upstream mainline GDB, and then modify the above
description in the commit message.

> Signed-off-by: Li Jian <lijian1@kylinos.cn>
> ---
>   bfd/elfnn-loongarch.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
> index 1eff3b134ee..efaebd76741 100644
> --- a/bfd/elfnn-loongarch.c
> +++ b/bfd/elfnn-loongarch.c
> @@ -6538,7 +6538,7 @@ loongarch_elf_copy_indirect_symbol (struct bfd_link_info *info,
>     _bfd_elf_link_hash_copy_indirect (info, dir, ind);
>   }
>   
> -#define PRSTATUS_SIZE		    0x1d8
> +#define PRSTATUS_SIZE		    0x1e0
>   #define PRSTATUS_OFFSET_PR_CURSIG   0xc
>   #define PRSTATUS_OFFSET_PR_PID	    0x20
>   #define ELF_GREGSET_T_SIZE	    0x168

The code looks good to me, but I can not approve and push it as GDB
maintainer for LoongArch because this change is related with the code
of binutils/bfd.

Thanks,
Tiezhu



More information about the Binutils mailing list