readelf: recognize FDO Packaging Metadata ELF note

As defined on: https://systemd.io/COREDUMP_PACKAGE_METADATA/
this note will be used starting from Fedora 36. Allow
readelf --notes to pretty print it:

Displaying notes found in: .note.package
  Owner                Data size 	Description
  FDO                  0x00000039	FDO_PACKAGING_METADATA
    Packaging Metadata: {"type":"deb","name":"fsverity-utils","version":"1.3-1"}

Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
This commit is contained in:
Luca Boccassi
2021-12-01 14:44:25 +00:00
committed by Nick Clifton
parent e1ccbd6d3a
commit e5382207cd
2 changed files with 18 additions and 0 deletions

View File

@ -19220,6 +19220,8 @@ get_note_type (Filedata * filedata, unsigned e_type)
return _("NT_SIGINFO (siginfo_t data)"); return _("NT_SIGINFO (siginfo_t data)");
case NT_FILE: case NT_FILE:
return _("NT_FILE (mapped files)"); return _("NT_FILE (mapped files)");
case FDO_PACKAGING_METADATA:
return _("FDO_PACKAGING_METADATA");
default: default:
break; break;
} }
@ -20446,6 +20448,17 @@ print_stapsdt_note (Elf_Internal_Note *pnote)
return false; return false;
} }
static bool
print_fdo_note (Elf_Internal_Note * pnote)
{
if (pnote->descsz > 0 && pnote->type == FDO_PACKAGING_METADATA)
{
printf (_(" Packaging Metadata: %.*s\n"), (int) pnote->descsz, pnote->descdata);
return true;
}
return false;
}
static const char * static const char *
get_ia64_vms_note_type (unsigned e_type) get_ia64_vms_note_type (unsigned e_type)
{ {
@ -21179,6 +21192,8 @@ process_note (Elf_Internal_Note * pnote,
return print_stapsdt_note (pnote); return print_stapsdt_note (pnote);
else if (startswith (pnote->namedata, "CORE")) else if (startswith (pnote->namedata, "CORE"))
return print_core_note (pnote); return print_core_note (pnote);
else if (startswith (pnote->namedata, "FDO"))
return print_fdo_note (pnote);
else if (((startswith (pnote->namedata, "GA") else if (((startswith (pnote->namedata, "GA")
&& strchr ("*$!+", pnote->namedata[2]) != NULL) && strchr ("*$!+", pnote->namedata[2]) != NULL)
|| strchr ("*$!+", pnote->namedata[0]) != NULL) || strchr ("*$!+", pnote->namedata[0]) != NULL)

View File

@ -997,6 +997,9 @@
#define NT_FREEBSD_ABI_TAG 1 #define NT_FREEBSD_ABI_TAG 1
/* Values for FDO .note.package notes as defined on https://systemd.io/COREDUMP_PACKAGE_METADATA/ */
#define FDO_PACKAGING_METADATA 0xcafe1a7e
/* These three macros disassemble and assemble a symbol table st_info field, /* These three macros disassemble and assemble a symbol table st_info field,
which contains the symbol binding and symbol type. The STB_ and STT_ which contains the symbol binding and symbol type. The STB_ and STT_
defines identify the binding and type. */ defines identify the binding and type. */