bfd/aarch64-linux: Support reading and writing the GCS core file note

Reviewed-By: Luis Machado <luis.machado@arm.com>
This commit is contained in:
Thiago Jung Bauermann
2025-05-01 16:48:15 -03:00
parent 10c6eff194
commit 2dae3f2531
2 changed files with 34 additions and 0 deletions

View File

@@ -10661,6 +10661,15 @@ elfcore_grok_aarch_zt (bfd *abfd, Elf_Internal_Note *note)
return elfcore_make_note_pseudosection (abfd, ".reg-aarch-zt", note); return elfcore_make_note_pseudosection (abfd, ".reg-aarch-zt", note);
} }
/* Convert NOTE into a bfd_section called ".reg-aarch-gcs". Return TRUE if
successful, otherwise return FALSE. */
static bool
elfcore_grok_aarch_gcs (bfd *abfd, Elf_Internal_Note *note)
{
return elfcore_make_note_pseudosection (abfd, ".reg-aarch-gcs", note);
}
static bool static bool
elfcore_grok_arc_v2 (bfd *abfd, Elf_Internal_Note *note) elfcore_grok_arc_v2 (bfd *abfd, Elf_Internal_Note *note)
{ {
@@ -11404,6 +11413,12 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
else else
return true; return true;
case NT_ARM_GCS:
if (note->namesz == 6 && strcmp (note->namedata, "LINUX") == 0)
return elfcore_grok_aarch_gcs (abfd, note);
else
return true;
case NT_GDB_TDESC: case NT_GDB_TDESC:
if (note->namesz == 4 if (note->namesz == 4
&& strcmp (note->namedata, "GDB") == 0) && strcmp (note->namedata, "GDB") == 0)
@@ -13074,6 +13089,20 @@ elfcore_write_aarch_zt (bfd *abfd,
size); size);
} }
/* Write the buffer of GCS register values in AARCH_GCS (length SIZE) into
the note buffer BUF and update *BUFSIZ. ABFD is the bfd the note is being
written into. Return a pointer to the new start of the note buffer, to
replace BUF which may no longer be valid. */
static char *
elfcore_write_aarch_gcs (bfd *abfd, char *buf, int *bufsiz,
const void *aarch_gcs, int size)
{
const char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz, note_name, NT_ARM_GCS,
aarch_gcs, size);
}
char * char *
elfcore_write_arc_v2 (bfd *abfd, elfcore_write_arc_v2 (bfd *abfd,
char *buf, char *buf,
@@ -13263,6 +13292,8 @@ elfcore_write_register_note (bfd *abfd,
return elfcore_write_aarch_za (abfd, buf, bufsiz, data, size); return elfcore_write_aarch_za (abfd, buf, bufsiz, data, size);
if (strcmp (section, ".reg-aarch-zt") == 0) if (strcmp (section, ".reg-aarch-zt") == 0)
return elfcore_write_aarch_zt (abfd, buf, bufsiz, data, size); return elfcore_write_aarch_zt (abfd, buf, bufsiz, data, size);
if (strcmp (section, ".reg-aarch-gcs") == 0)
return elfcore_write_aarch_gcs (abfd, buf, bufsiz, data, size);
if (strcmp (section, ".reg-arc-v2") == 0) if (strcmp (section, ".reg-arc-v2") == 0)
return elfcore_write_arc_v2 (abfd, buf, bufsiz, data, size); return elfcore_write_arc_v2 (abfd, buf, bufsiz, data, size);
if (strcmp (section, ".gdb-tdesc") == 0) if (strcmp (section, ".gdb-tdesc") == 0)

View File

@@ -740,6 +740,9 @@
/* Note: name must be "LINUX". */ /* Note: name must be "LINUX". */
#define NT_ARM_ZT 0x40d /* AArch64 SME2 ZT registers. */ #define NT_ARM_ZT 0x40d /* AArch64 SME2 ZT registers. */
/* Note: name must be "LINUX". */ /* Note: name must be "LINUX". */
#define NT_ARM_GCS 0x410 /* AArch64 Guarded Control Stack
registers. */
/* Note name must be "LINUX". */
#define NT_ARC_V2 0x600 /* ARC HS accumulator/extra registers. */ #define NT_ARC_V2 0x600 /* ARC HS accumulator/extra registers. */
/* note name must be "LINUX". */ /* note name must be "LINUX". */
#define NT_LARCH_CPUCFG 0xa00 /* LoongArch CPU config registers */ #define NT_LARCH_CPUCFG 0xa00 /* LoongArch CPU config registers */