readelf: add pretty printing for FDO Dlopen Metadata note

Message ID 20240510221649.1207746-1-luca.boccassi@gmail.com
State New
Headers
Series readelf: add pretty printing for FDO Dlopen Metadata note |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Testing passed

Commit Message

Luca Boccassi May 10, 2024, 10:16 p.m. UTC
  From: Luca Boccassi <bluca@debian.org>

Note that the webpage in the comment is not published yet,
it will be next week when the next systemd RC is tagged.
The document can be viewed right now on github at:
https://github.com/systemd/systemd/blob/main/docs/ELF_DLOPEN_METADATA.md

But the node ID and the string format are now fixed, even
if the content of the string might change, it will still be
a string.

Signed-off-by: Luca Boccassi <bluca@debian.org>
---
 binutils/readelf.c   | 7 +++++++
 include/elf/common.h | 3 +++
 2 files changed, 10 insertions(+)
  

Comments

Nick Clifton May 20, 2024, 2:42 p.m. UTC | #1
Hi Luca,

> Note that the webpage in the comment is not published yet,
> it will be next week when the next systemd RC is tagged.
> The document can be viewed right now on github at:
> https://github.com/systemd/systemd/blob/main/docs/ELF_DLOPEN_METADATA.md
> 
> But the node ID and the string format are now fixed, even
> if the content of the string might change, it will still be
> a string.

Approved - please apply.

Cheers
  Nick
  
Luca Boccassi May 20, 2024, 2:43 p.m. UTC | #2
On Mon, 20 May 2024 at 15:42, Nick Clifton <nickc@redhat.com> wrote:
>
> Hi Luca,
>
> > Note that the webpage in the comment is not published yet,
> > it will be next week when the next systemd RC is tagged.
> > The document can be viewed right now on github at:
> > https://github.com/systemd/systemd/blob/main/docs/ELF_DLOPEN_METADATA.md
> >
> > But the node ID and the string format are now fixed, even
> > if the content of the string might change, it will still be
> > a string.
>
> Approved - please apply.

Hi,

Thank you - please note that I do not have push permissions, so cannot
apply it myself.
  
Nick Clifton May 20, 2024, 3:47 p.m. UTC | #3
Hi Luca,

>> Approved - please apply.

> Thank you - please note that I do not have push permissions, so cannot
> apply it myself.

Applied. :-)

Cheers
   Nick
  

Patch

diff --git a/binutils/readelf.c b/binutils/readelf.c
index f8305b4715b..2fb5f977ec0 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -20518,6 +20518,8 @@  get_note_type (Filedata * filedata, unsigned e_type)
 	return _("GO BUILDID");
       case FDO_PACKAGING_METADATA:
 	return _("FDO_PACKAGING_METADATA");
+      case FDO_DLOPEN_METADATA:
+	return _("FDO_DLOPEN_METADATA");
       default:
 	break;
       }
@@ -21777,6 +21779,11 @@  print_fdo_note (Elf_Internal_Note * pnote)
       printf (_("    Packaging Metadata: %.*s\n"), (int) pnote->descsz, pnote->descdata);
       return true;
     }
+  if (pnote->descsz > 0 && pnote->type == FDO_DLOPEN_METADATA)
+    {
+      printf (_("    Dlopen Metadata: %.*s\n"), (int) pnote->descsz, pnote->descdata);
+      return true;
+    }
   return false;
 }
 
diff --git a/include/elf/common.h b/include/elf/common.h
index 832f9bd510f..7e62c34643c 100644
--- a/include/elf/common.h
+++ b/include/elf/common.h
@@ -1037,6 +1037,9 @@ 
 /* Values for FDO .note.package notes as defined on https://systemd.io/COREDUMP_PACKAGE_METADATA/  */
 #define FDO_PACKAGING_METADATA	0xcafe1a7e
 
+/* Values for FDO .note.dlopen notes as defined on https://systemd.io/ELF_DLOPEN_METADATA/  */
+#define FDO_DLOPEN_METADATA 0x407c0c0a
+
 /* These three macros disassemble and assemble a symbol table st_info field,
    which contains the symbol binding and symbol type.  The STB_ and STT_
    defines identify the binding and type.  */