]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
bfd/riscv: prepare to handle bare metal core dump creation
authorAndrew Burgess <andrew.burgess@embecosm.com>
Mon, 30 Nov 2020 12:14:38 +0000 (12:14 +0000)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Fri, 5 Mar 2021 17:21:41 +0000 (17:21 +0000)
commit0897bb7d6dc4e803cd99d4656186c965f099d01c
treec41cc4d854484dbc98aa8f63ff904a85862cfaed
parent95ce627aeb9df14bdaf70faf67054cb953678797
bfd/riscv: prepare to handle bare metal core dump creation

When creating a core file GDB will call the function
elfcore_write_prstatus to write out the general purpose registers
along with the pid/tid for the thread (into a prstatus structure) and
the executable name and arguments (into a prpsinfo_t structure).

However, for a bare metal RISC-V tool chain the prstatus_t and
prpsinfo_t types are not defined so the elfcore_write_prstatus
function will return NULL, preventing core file creation.

This commit provides the `elf_backend_write_core_note' hook and uses
the provided function to write out the required information.

In order to keep changes in the non bare metal tools to a minimum, the
provided backend function will itself return NULL when the prstatus_t
or pspsinfo_t types are available, the consequence of this is that the
generic code in elfcore_write_prstatus will be used just as before.
But, when prstatus_t or prpsinfo_t is not available, the new backend
function will write out the information using predefined offsets.

This new functionality will be used by a later GDB commit that will
add bare metal core dumps for RISC-V.

bfd/ChangeLog:

* elfnn-riscv.c (PRPSINFO_PR_FNAME_LENGTH): Define.
(PRPSINFO_PR_PSARGS_LENGTH): Define.
(riscv_write_core_note): New function.
(riscv_elf_grok_psinfo): Make use of two new length defines.
(elf_backend_write_core_note): Define.
bfd/ChangeLog
bfd/elfnn-riscv.c