[PATCH v2 0/1] bfd/loongarch: set PRSTATUS_SIZE=0x1e0 to match kernel's struct elf_prstatus size
lijian1@kylinos.cn
lijian1@kylinos.cn
Fri Oct 31 06:24:20 GMT 2025
From: Li Jian <lijian1@kylinos.cn>
Hi Tiezhu,
Thank you for taking the time to review my patch.
These are the results for the size trace:
In the gdb-14.1-5, there is the warning message and data print about the warning:
gdb -q -ex "file /usr/bin/gdb" -nx -ex "break core_target_open" -ex "break loongarch_iterate_over_regset_sections" -ex "break _bfd_elfcore_make_pseudosection" -ex "break core_target::get_core_register_section" -ex "run -nx -ex 'file /bin/bash' -ex 'set pagination off' -ex 'set debug arch 1' -ex 'core-file core.3925.bash' -ex '-d /root/code/gdb/binutils-gdb'"
Thread 1 "gdb" hit Breakpoint 3, _bfd_elfcore_make_pseudosection (abfd=0x555556467aa0, name=0x555555d2ac98 ".reg", size=360, filepos=1652) at ../../bfd/elf.c:10328
10328 {
(gdb) c
Continuing.
Thread 1 "gdb" hit Breakpoint 3, _bfd_elfcore_make_pseudosection (abfd=0x555556467aa0, name=0x555555da3150 ".note.linuxcore.file", size=950, filepos=2552) at ../../bfd/elf.c:10328
10328 {
(gdb) c
Continuing.
gdbarch_find_by_info: info.bfd_arch_info Loongarch64
gdbarch_find_by_info: info.byte_order 1 (little)
gdbarch_find_by_info: info.osabi 5 (GNU/Linux)
gdbarch_find_by_info: info.abfd 0x555556467aa0
gdbarch_find_by_info: Previous architecture 0x55555622d440 (Loongarch64) selected
[New LWP 3925]
Thread 1 "gdb" hit Breakpoint 2, loongarch_iterate_over_regset_sections (gdbarch=0x55555622d440, cb=0x5555557e1750 <get_core_registers_cb(char const*, int, int, regset const*, char const*, void*)>, cb_data=0x7ffffffd2758, regcache=0x0)
at ../../gdb/loongarch-linux-tdep.c:265
265 {
(gdb) c
Continuing.
Thread 1 "gdb" hit Breakpoint 4, core_target::get_core_register_section (this=0x555556456670, regcache=0x5555563b74c0, regset=0x555555fe7238 <loongarch_gregset>, name=0x555555d2ac98 ".reg", section_min_size=280,
human_name=0x555555d73e50 "general-purpose", required=true) at ../../gdb/corelow.c:854
854 {
(gdb) c
Continuing.
warning: Unexpected size of section `.reg/3925' in core file.
Thread 1 "gdb" hit Breakpoint 4, core_target::get_core_register_section (this=0x555556456670, regcache=0x5555563b74c0, regset=0x555555fe7218 <loongarch_fpregset>, name=0x555555d2ace0 ".reg2", section_min_size=268,
human_name=0x555555d73e60 "floating-point", required=false) at ../../gdb/corelow.c:854
854 {
(gdb) c
Continuing.
gdbarch_find_by_info: info.bfd_arch_info Loongarch64
gdbarch_find_by_info: info.byte_order 1 (little)
gdbarch_find_by_info: info.osabi 5 (GNU/Linux)
gdbarch_find_by_info: info.abfd 0x555556453590
gdbarch_find_by_info: Previous architecture 0x55555622d440 (Loongarch64) selected
Core was generated by ` '.
Thread 1 "gdb" hit Breakpoint 2, loongarch_iterate_over_regset_sections (gdbarch=0x55555622d440, cb=0x5555557e1750 <get_core_registers_cb(char const*, int, int, regset const*, char const*, void*)>, cb_data=0x7ffffffd29f8, regcache=0x0)
at ../../gdb/loongarch-linux-tdep.c:265
265 {
Notice that for general-purpose registers, the section_min_size is 280 bytes while the actual size is 360 bytes.
According to the definition of LOONGARCH_LINUX_NUM_GREGSET in GDB 14.1-5, its value is 35 then the len is calced to 35*8=280(bytes).
Therefore, the warning is triggered due to the LOONGARCH_LINUX_NUM_GREGSET value, not because of the PRSTATUS_SIZE value.
Therefore, if PRSTATUS_SIZE is inconsistent with the kernel’s struct elf_prstatus, the LoongArch64 backend logic will not be taken, resulting in an incorrect code path without observable failure.
Best regards,
Li Jian
More information about the Binutils
mailing list